[pisa-src] r1692 - trunk/community-operator/co_client.c

  • From: Mircea Gherzan <mircea.gherzan@xxxxxxxxxxxxxx>
  • To: pisa-src@xxxxxxxxxxxxx
  • Date: Mon, 16 Nov 2009 16:06:08 +0100

Author: gherzan
Date: Mon Nov 16 16:06:08 2009
New Revision: 1692

Log:
co: refactor check_certs_dir()

Cut off one level of identation by adding the return statement
right after the error signaling.

Modified:
   trunk/community-operator/co_client.c

Modified: trunk/community-operator/co_client.c
==============================================================================
--- trunk/community-operator/co_client.c        Mon Nov 16 15:54:57 2009        
(r1691)
+++ trunk/community-operator/co_client.c        Mon Nov 16 16:06:08 2009        
(r1692)
@@ -463,38 +463,42 @@
        n = scandir(co_client_config.certs_dir, &namelist, 0, alphasort);
        if (n < 0) {
                perror("scandir");
-       } else {
-               for (i = 0; i < n && !found; i++) {
-                       // Skip . and ..
-                       if (strcmp(namelist[i]->d_name, ".") != 0 &&
-                                       strcmp(namelist[i]->d_name, "..") != 0) 
{
-                               result = is_valid_cert(namelist[i]->d_name);
-                               snprintf((char *) path, sizeof(path), "%s/%s",
-                                               co_client_config.certs_dir, 
namelist[i]->d_name);
-
-                               // Certificate expired
-                               // Remove certificate
-                               if (result == -1) {
-                                       PISA_DEBUG(PL_GENERIC, "Removing 
cert...\n");
-                                       if (remove(path) != 0) {
-                                               perror("Removing cert failed");
-                                       }
-                               } else if (result) {
-                                       found = 1;
-                                       // It is a new certificate
-                                       // Copy to final destination
-                                       if (strcmp(path, last_used_cert) != 0) {
-                                               strncpy(last_used_cert, path, 
PATH_BUFFER);
-                                               PISA_DEBUG(PL_GENERIC, "Found 
valid cert.\n");
-                                               PISA_DEBUG(PL_GENERIC, "Copying 
to cert location...\n");
-                                               copy_cert(path, 
co_client_config.cert_filename);
-                                       }
+               return found;
+       }
+               
+       for (i = 0; i < n && !found; i++) {
+               // Skip . and ..
+               if (strcmp(namelist[i]->d_name, ".") != 0 &&
+                       strcmp(namelist[i]->d_name, "..") != 0) {
+               
+                       result = is_valid_cert(namelist[i]->d_name);
+                       snprintf((char *) path, sizeof(path), "%s/%s",
+                                       co_client_config.certs_dir, 
namelist[i]->d_name);
+
+                       // Certificate expired
+                       // Remove certificate
+                       if (result == -1) {
+                               PISA_DEBUG(PL_GENERIC, "Removing cert...\n");
+                               if (remove(path) != 0) {
+                                       perror("Removing cert failed");
+                               }
+                       } else if (result) {
+                               found = 1;
+                               // It is a new certificate
+                               // Copy to final destination
+                               if (strcmp(path, last_used_cert) != 0) {
+                                       strncpy(last_used_cert, path, 
PATH_BUFFER);
+                                       PISA_DEBUG(PL_GENERIC, "Found valid 
cert.\n");
+                                       PISA_DEBUG(PL_GENERIC, "Copying to cert 
location...\n");
+                                       copy_cert(path, 
co_client_config.cert_filename);
                                }
                        }
-                       free(namelist[i]);
                }
-               free(namelist);
+               free(namelist[i]);
        }
+
+       free(namelist);
+       
        return found;
 }
 

Other related posts:

  • » [pisa-src] r1692 - trunk/community-operator/co_client.c - Mircea Gherzan