From: nekral-guest Date: Tue, 10 Jun 2008 20:01:55 +0000 (+0000) Subject: * lib/nscd.c: Include defines.h. X-Git-Tag: 4.1.3~409 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef1a2a82dde6833d977de989564f426869257c6e;p=shadow * 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. --- diff --git a/ChangeLog b/ChangeLog index 9c25e986..dea2301b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-06-10 Nicolas François + + * 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 * lib/port.c: Add brackets and parenthesis. diff --git a/lib/nscd.c b/lib/nscd.c index 10cb69c3..f71df369 100644 --- a/lib/nscd.c +++ b/lib/nscd.c @@ -11,8 +11,11 @@ #include #include #include +#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; }