* lib/nscd.c: Include defines.h.
authornekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 10 Jun 2008 20:01:55 +0000 (20:01 +0000)
committernekral-guest <nekral-guest@5a98b0ae-9ef6-0310-add3-de5d479b70d7>
Tue, 10 Jun 2008 20:01:55 +0000 (20:01 +0000)
* lib/nscd.c: Always warn when the nscd cache cannot be flushed.
* lib/nscd.c: Avoid assignments in comparisons.
* lib/nscd.c: Ignore the return value of fputs() when printing
errors.

ChangeLog
lib/nscd.c

index 9c25e9863c826149a0bb94de04d53c4633aeb916..dea2301b14f70052dd18784cfe00690877be21ea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-06-10  Nicolas François  <nicolas.francois@centraliens.net>
+
+       * lib/nscd.c: Include defines.h.
+       * lib/nscd.c: Always warn when the nscd cache cannot be flushed.
+       * lib/nscd.c: Avoid assignments in comparisons.
+       * lib/nscd.c: Ignore the return value of fputs() when printing
+       errors.
+
 2008-06-10  Nicolas François  <nicolas.francois@centraliens.net>
 
        * lib/port.c: Add brackets and parenthesis.
index 10cb69c344ae0656b3b32818096b246c8c3e8dcb..f71df3693ea85fd3c81cce77b4146c13fbc8c2a0 100644 (file)
 #include <errno.h>
 #include <sys/wait.h>
 #include <sys/types.h>
+#include "defines.h"
 #include "nscd.h"
 
+#define MSG_NSCD_FLUSH_CACHE_FAILED "Failed to flush the nscd cache.\n"
+
 /*
  * nscd_flush_cache - flush specified service buffer in nscd cache
  */
@@ -24,24 +27,28 @@ int nscd_flush_cache (const char *service)
        char *spawnedEnv[] = {NULL};
 
        /* spawn process */
-       if( (err=posix_spawn(&pid, spawnedArgs[0], NULL, NULL,
-                            spawnedArgs, spawnedEnv)) !=0 ) 
+       err = posix_spawn(&pid, spawnedArgs[0], NULL, NULL,
+                         spawnedArgs, spawnedEnv);
+       if(0 != err)
        {
-               fprintf(stderr, "posix_spawn() error=%d\n", err);
+               (void) fputs (_(MSG_NSCD_FLUSH_CACHE_FAILED), stderr);
+               (void) fprintf (stderr, "posix_spawn() error=%d\n", err);
                return -1;
        }
 
-       /* Wait for the spawned process to exit */      
+       /* Wait for the spawned process to exit */
        termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
-       if (termpid == -1)
+       if (-1 == termpid)
        {
+               (void) fputs (_(MSG_NSCD_FLUSH_CACHE_FAILED), stderr);
                perror("waitpid");
                return -1;
        }
        else if (termpid != pid)
        {
-               fprintf(stderr, "waitpid returned %ld != %ld\n",
-                        (long int) termpid, (long int) pid);
+               (void) fputs (_(MSG_NSCD_FLUSH_CACHE_FAILED), stderr);
+               (void) fprintf (stderr, "waitpid returned %ld != %ld\n",
+                              (long int) termpid, (long int) pid);
                return -1;
        }