amoralej / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 years ago
Clone

Blame SOURCES/0009-Ticket-48919-Compiler-warnings-while-building-389-ds.patch

7c7f29
From 3fbe8ab77452998fd646bf26ee8162aab0ae8659 Mon Sep 17 00:00:00 2001
7c7f29
From: Noriko Hosoi <nhosoi@redhat.com>
7c7f29
Date: Wed, 13 Jul 2016 18:59:01 -0700
7c7f29
Subject: [PATCH 09/15] Ticket #48919 - Compiler warnings while building
7c7f29
 389-ds-base on RHEL7
7c7f29
7c7f29
Description: Cleaned up warnings from gcc and clang.
7c7f29
7c7f29
https://fedorahosted.org/389/ticket/48919
7c7f29
7c7f29
Reviewed by wibrown@redhat.com (Thank you, William!!)
7c7f29
7c7f29
(cherry picked from commit 18c6029f64c48b330a101cbadceb8293d39bf5e2)
7c7f29
---
7c7f29
 ldap/servers/plugins/acl/acllas.c                  |  1 -
7c7f29
 ldap/servers/slapd/agtmmap.c                       | 10 +++++++++-
7c7f29
 ldap/servers/slapd/back-ldbm/idl_new.c             |  4 ++--
7c7f29
 .../servers/slapd/back-ldbm/ldbm_instance_config.c |  5 +++++
7c7f29
 ldap/servers/slapd/back-ldbm/ldif2ldbm.c           | 15 ++++++++++-----
7c7f29
 ldap/servers/slapd/detach.c                        | 11 +++++++----
7c7f29
 ldap/servers/slapd/localhost.c                     | 10 +++++++---
7c7f29
 ldap/servers/slapd/protect_db.c                    | 22 +++++++++++++++-------
7c7f29
 ldap/servers/slapd/protect_db.h                    |  3 +++
7c7f29
 ldap/servers/slapd/saslbind.c                      |  3 +++
7c7f29
 ldap/servers/slapd/tools/ldclt/ldapfct.c           |  5 ++++-
7c7f29
 ldap/servers/slapd/tools/ldif.c                    |  5 ++++-
7c7f29
 ldap/servers/slapd/tools/mmldif.c                  | 20 ++++++++++++--------
7c7f29
 ldap/servers/slapd/util.c                          |  9 ++++++---
7c7f29
 ldap/servers/snmp/main.c                           | 15 ++++++++++++---
7c7f29
 lib/base/file.cpp                                  |  1 -
7c7f29
 lib/base/fsmutex.cpp                               | 10 +++++++---
7c7f29
 17 files changed, 106 insertions(+), 43 deletions(-)
7c7f29
7c7f29
diff --git a/ldap/servers/plugins/acl/acllas.c b/ldap/servers/plugins/acl/acllas.c
7c7f29
index ff9b450..47ac0b8 100644
7c7f29
--- a/ldap/servers/plugins/acl/acllas.c
7c7f29
+++ b/ldap/servers/plugins/acl/acllas.c
7c7f29
@@ -190,7 +190,6 @@ extern int ldapu_member_certificate_match (void* cert, const char* desc);
7c7f29
 /****************************************************************************/
7c7f29
 /* Defines, Constants, ande Declarations                                    */
7c7f29
 /****************************************************************************/
7c7f29
-static char* const   	type_objectClass = "objectclass";
7c7f29
 static char* const 	filter_groups = "(|(objectclass=groupOfNames) (objectclass=groupOfUniqueNames)(objectclass=groupOfCertificates)(objectclass=groupOfURLs))";
7c7f29
 static char* const	type_member = "member";
7c7f29
 static char* const	type_uniquemember = "uniquemember";
7c7f29
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
7c7f29
index 6f72d57..629bc1b 100644
7c7f29
--- a/ldap/servers/slapd/agtmmap.c
7c7f29
+++ b/ldap/servers/slapd/agtmmap.c
7c7f29
@@ -160,7 +160,15 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
7c7f29
                {
7c7f29
                    /* Without this we will get segv when we try to read/write later */
7c7f29
                    buf = calloc (1, sz);
7c7f29
-                   (void)write (fd, buf, sz);
7c7f29
+                   if (write(fd, buf, sz) < 0) {
7c7f29
+                       err = errno;
7c7f29
+#if (0)
7c7f29
+                       fprintf (stderr, "write failed errno=%d from %s(line: %d)\n", err, __FILE__, __LINE__);
7c7f29
+#endif
7c7f29
+                       rc = err;
7c7f29
+                       free (buf);
7c7f29
+                       goto bail;
7c7f29
+                   }
7c7f29
                    free (buf);
7c7f29
                }
7c7f29
 
7c7f29
diff --git a/ldap/servers/slapd/back-ldbm/idl_new.c b/ldap/servers/slapd/back-ldbm/idl_new.c
7c7f29
index 63df49f..a8d76d8 100644
7c7f29
--- a/ldap/servers/slapd/back-ldbm/idl_new.c
7c7f29
+++ b/ldap/servers/slapd/back-ldbm/idl_new.c
7c7f29
@@ -403,8 +403,8 @@ idl_new_range_fetch(
7c7f29
     time_t curtime;
7c7f29
     void *saved_key = NULL;
7c7f29
     int coreop = operator & SLAPI_OP_RANGE;
7c7f29
-    ID key;
7c7f29
-    ID suffix;
7c7f29
+    ID key = 0xff; /* random- to suppress compiler warning */
7c7f29
+    ID suffix = 0; /* random- to suppress compiler warning */
7c7f29
     idl_range_id_pair *leftover = NULL;
7c7f29
     size_t leftoverlen = 32;
7c7f29
     int leftovercnt = 0;
7c7f29
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
7c7f29
index 9302410..698be66 100644
7c7f29
--- a/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
7c7f29
+++ b/ldap/servers/slapd/back-ldbm/ldbm_instance_config.c
7c7f29
@@ -1155,6 +1155,11 @@ ldbm_instance_post_delete_instance_entry_callback(Slapi_PBlock *pb, Slapi_Entry*
7c7f29
                             rc = PR_Delete(dbp);
7c7f29
                         }
7c7f29
                         PR_ASSERT(rc == 0);
7c7f29
+                        if (rc != 0) {
7c7f29
+                            LDAPDebug1Arg(LDAP_DEBUG_ANY,
7c7f29
+                                "ldbm_instance_post_delete_instance_entry_callback:"
7c7f29
+                                " failed to delete %s\n", dbp);
7c7f29
+                        }
7c7f29
                         PR_smprintf_free(dbp);
7c7f29
                     }
7c7f29
                     PR_CloseDir(dirhandle);                
7c7f29
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
7c7f29
index 0b2eab2..52338c2 100644
7c7f29
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
7c7f29
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
7c7f29
@@ -1009,7 +1009,6 @@ export_one_entry(struct ldbminfo *li,
7c7f29
         }
7c7f29
         slapi_ch_free_string(&pw;;
7c7f29
     }
7c7f29
-    rc = 0;
7c7f29
     data.data = slapi_entry2str_with_options(expargs->ep->ep_entry,
7c7f29
                                              &len, expargs->options);
7c7f29
     data.size = len + 1;
7c7f29
@@ -1018,10 +1017,14 @@ export_one_entry(struct ldbminfo *li,
7c7f29
         char idstr[32];
7c7f29
         
7c7f29
         sprintf(idstr, "# entry-id: %lu\n", (u_long)expargs->ep->ep_id);
7c7f29
-        write(expargs->fd, idstr, strlen(idstr));
7c7f29
+        rc = write(expargs->fd, idstr, strlen(idstr));
7c7f29
+        PR_ASSERT(rc > 0);
7c7f29
     }
7c7f29
-    write(expargs->fd, data.data, len);
7c7f29
-    write(expargs->fd, "\n", 1);
7c7f29
+    rc = write(expargs->fd, data.data, len);
7c7f29
+    PR_ASSERT(rc > 0);
7c7f29
+    rc = write(expargs->fd, "\n", 1);
7c7f29
+    PR_ASSERT(rc > 0);
7c7f29
+    rc = 0;
7c7f29
     if ((*expargs->cnt) % 1000 == 0) {
7c7f29
         int percent;
7c7f29
 
7c7f29
@@ -1350,7 +1353,9 @@ ldbm_back_ldbm2ldif( Slapi_PBlock *pb )
7c7f29
                  */
7c7f29
 
7c7f29
         sprintf(vstr, "version: %d\n\n", myversion);
7c7f29
-        write(fd, vstr, strlen(vstr));
7c7f29
+        rc = write(fd, vstr, strlen(vstr));
7c7f29
+        PR_ASSERT(rc > 0);
7c7f29
+		rc = 0;
7c7f29
     }
7c7f29
 
7c7f29
     eargs.decrypt = decrypt;
7c7f29
diff --git a/ldap/servers/slapd/detach.c b/ldap/servers/slapd/detach.c
7c7f29
index b5af952..b055a5c 100644
7c7f29
--- a/ldap/servers/slapd/detach.c
7c7f29
+++ b/ldap/servers/slapd/detach.c
7c7f29
@@ -48,7 +48,7 @@ int
7c7f29
 detach( int slapd_exemode, int importexport_encrypt,
7c7f29
         int s_port, daemon_ports_t *ports_info )
7c7f29
 {
7c7f29
-	int		i, sd;
7c7f29
+	int i, sd, rc;
7c7f29
 	char *workingdir = 0;
7c7f29
 	char *errorlog = 0;
7c7f29
 	char *ptr = 0;
7c7f29
@@ -84,13 +84,15 @@ detach( int slapd_exemode, int importexport_encrypt,
7c7f29
 		if ( NULL == workingdir ) {
7c7f29
 			errorlog = config_get_errorlog();
7c7f29
 			if ( NULL == errorlog ) {
7c7f29
-				(void) chdir( "/" );
7c7f29
+				rc = chdir( "/" );
7c7f29
+				PR_ASSERT(rc == 0);
7c7f29
 			} else {
7c7f29
 				if ((ptr = strrchr(errorlog, '/')) ||
7c7f29
 					(ptr = strrchr(errorlog, '\\'))) {
7c7f29
 					*ptr = 0;
7c7f29
 				}
7c7f29
-				(void) chdir( errorlog );
7c7f29
+				rc = chdir( errorlog );
7c7f29
+				PR_ASSERT(rc == 0);
7c7f29
 				config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, errorlog, NULL, 1);
7c7f29
 				slapi_ch_free_string(&errorlog);
7c7f29
 			}
7c7f29
@@ -99,7 +101,8 @@ detach( int slapd_exemode, int importexport_encrypt,
7c7f29
 			if (config_set_workingdir(CONFIG_WORKINGDIR_ATTRIBUTE, workingdir, NULL, 0) == LDAP_OPERATIONS_ERROR) {
7c7f29
 				return 1;
7c7f29
 			}
7c7f29
-			(void) chdir( workingdir );
7c7f29
+			rc = chdir( workingdir );
7c7f29
+			PR_ASSERT(rc == 0);
7c7f29
 			slapi_ch_free_string(&workingdir);
7c7f29
 		}
7c7f29
 
7c7f29
diff --git a/ldap/servers/slapd/localhost.c b/ldap/servers/slapd/localhost.c
7c7f29
index 2c40493..7b4e903 100644
7c7f29
--- a/ldap/servers/slapd/localhost.c
7c7f29
+++ b/ldap/servers/slapd/localhost.c
7c7f29
@@ -118,9 +118,13 @@ find_localhost_DNS()
7c7f29
 #ifndef NO_DOMAINNAME
7c7f29
     if (domain == NULL) {
7c7f29
         /* No domain found. Try getdomainname. */
7c7f29
-        getdomainname (line, sizeof(line));
7c7f29
-        LDAPDebug (LDAP_DEBUG_CONFIG, "getdomainname(%s)\n", line, 0, 0);
7c7f29
-        if (line[0] != 0) {
7c7f29
+        line[0] = '\0';
7c7f29
+        if (getdomainname(line, sizeof(line)) < 0) { /* failure */
7c7f29
+            slapi_log_error(SLAPI_LOG_FATAL, "localhost_DNS", "getdomainname failed\n");
7c7f29
+        } else {
7c7f29
+            slapi_log_error(SLAPI_LOG_CONFIG, "localhost_DNS", "getdomainname(%s)\n", line);
7c7f29
+        }
7c7f29
+        if (line[0] != '\0') {
7c7f29
             domain = &line[0];
7c7f29
         }
7c7f29
     }
7c7f29
diff --git a/ldap/servers/slapd/protect_db.c b/ldap/servers/slapd/protect_db.c
7c7f29
index b22daa1..4579852 100644
7c7f29
--- a/ldap/servers/slapd/protect_db.c
7c7f29
+++ b/ldap/servers/slapd/protect_db.c
7c7f29
@@ -42,7 +42,7 @@ grab_lockfile()
7c7f29
 {
7c7f29
     pid_t pid, owning_pid;
7c7f29
     char lockfile[MAXPATHLEN];
7c7f29
-    int fd, x;
7c7f29
+    int fd, x, rc;
7c7f29
     int removed_lockfile = 0;
7c7f29
     struct timeval t;
7c7f29
     slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
7c7f29
@@ -60,8 +60,12 @@ grab_lockfile()
7c7f29
     /* Try to grab it */
7c7f29
     if ((fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL, 0644)) != -1) {
7c7f29
         /* We got the lock, write our pid to the file */
7c7f29
-        write(fd, (void *) &pid, sizeof(pid_t));
7c7f29
-    close(fd);
7c7f29
+        rc = write(fd, (void *) &pid, sizeof(pid_t));
7c7f29
+        close(fd);
7c7f29
+        if (rc < 0) {
7c7f29
+            fprintf(stderr, ERROR_WRITING_LOCKFILE, lockfile);
7c7f29
+            return rc;
7c7f29
+        }
7c7f29
         return 0;
7c7f29
     }
7c7f29
      
7c7f29
@@ -74,13 +78,17 @@ grab_lockfile()
7c7f29
 
7c7f29
     while(1) {
7c7f29
         /* Try to grab the lockfile NUM_TRIES times waiting WAIT_TIME milliseconds after each try */
7c7f29
-    t.tv_sec = 0;
7c7f29
-    t.tv_usec = WAIT_TIME * 1000;
7c7f29
+        t.tv_sec = 0;
7c7f29
+        t.tv_usec = WAIT_TIME * 1000;
7c7f29
         for(x = 0; x < NUM_TRIES; x++) {
7c7f29
             if ((fd = open(lockfile, O_RDWR | O_CREAT | O_EXCL, 0644)) != -1) {
7c7f29
                 /* Got the lock */
7c7f29
-                write(fd, (void *) &pid, sizeof(pid_t));
7c7f29
-        close(fd);
7c7f29
+                rc = write(fd, (void *) &pid, sizeof(pid_t));
7c7f29
+                close(fd);
7c7f29
+                if (rc < 0) {
7c7f29
+                    fprintf(stderr, ERROR_WRITING_LOCKFILE, lockfile);
7c7f29
+                    return rc;
7c7f29
+                }
7c7f29
                 return 0;
7c7f29
             }
7c7f29
             select(0, NULL, NULL, NULL, &t);
7c7f29
diff --git a/ldap/servers/slapd/protect_db.h b/ldap/servers/slapd/protect_db.h
7c7f29
index 0f729a2..66adfb3 100644
7c7f29
--- a/ldap/servers/slapd/protect_db.h
7c7f29
+++ b/ldap/servers/slapd/protect_db.h
7c7f29
@@ -26,6 +26,9 @@ void remove_slapd_process();
7c7f29
 #define ERROR_ACCESSING_LOCKFILE "Error - Problem accessing the lockfile %s\n" 
7c7f29
   /* name of lockfile */
7c7f29
 
7c7f29
+#define ERROR_WRITING_LOCKFILE "Error - Problem writing the lockfile %s\n" 
7c7f29
+  /* name of lockfile */
7c7f29
+
7c7f29
 #define LOCKFILE_DEAD_OWNER "Error - The lockfile, %s, is held by process %d,\nwhich no longer seems to be running.  If this is\nthe case, please remove the lockfile\n"
7c7f29
   /* name of lockfile, pid of owning process */
7c7f29
 
7c7f29
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
7c7f29
index eb68209..37175f4 100644
7c7f29
--- a/ldap/servers/slapd/saslbind.c
7c7f29
+++ b/ldap/servers/slapd/saslbind.c
7c7f29
@@ -547,6 +547,9 @@ int ids_sasl_init(void)
7c7f29
     LDAPDebug( LDAP_DEBUG_TRACE, "=> ids_sasl_init\n", 0, 0, 0 );
7c7f29
 
7c7f29
     PR_ASSERT(inited == 0);
7c7f29
+    if (inited != 0) {
7c7f29
+        LDAPDebug0Args(LDAP_DEBUG_ANY, "ids_sasl_init is called more than once.\n");
7c7f29
+    }
7c7f29
     inited = 1;
7c7f29
 
7c7f29
     serverfqdn = get_localhost_DNS();
7c7f29
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
7c7f29
index e13983d..f084cb4 100644
7c7f29
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
7c7f29
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
7c7f29
@@ -2552,7 +2552,10 @@ int	 ldclt_write_genldif_nb;
7c7f29
 void
7c7f29
 ldclt_flush_genldif (void)
7c7f29
 {
7c7f29
-  write (mctx.genldifFile, ldclt_write_genldif_buf, ldclt_write_genldif_nb);
7c7f29
+  if (write (mctx.genldifFile, ldclt_write_genldif_buf, ldclt_write_genldif_nb) < 0) {
7c7f29
+    printf("ldclt[%d]: ldclt_flush_genldif: Failed to write (%s) error=%d\n",
7c7f29
+           mctx.pid, ldclt_write_genldif_buf, errno);
7c7f29
+  }
7c7f29
   ldclt_write_genldif_pt = ldclt_write_genldif_buf;
7c7f29
   ldclt_write_genldif_nb = 0;
7c7f29
 }
7c7f29
diff --git a/ldap/servers/slapd/tools/ldif.c b/ldap/servers/slapd/tools/ldif.c
7c7f29
index 1050fbd..5973c6b 100644
7c7f29
--- a/ldap/servers/slapd/tools/ldif.c
7c7f29
+++ b/ldap/servers/slapd/tools/ldif.c
7c7f29
@@ -132,7 +132,10 @@ int main( int argc, char **argv )
7c7f29
 					free( buf );
7c7f29
 					return( 1 );
7c7f29
 				}
7c7f29
-				(void)fgets(buf+curlen, maxlen/2 + 1, stdin);
7c7f29
+				if (NULL == fgets(buf+curlen, maxlen/2 + 1, stdin)) {
7c7f29
+					/* no more input to read. */
7c7f29
+					break;
7c7f29
+				}
7c7f29
 			}
7c7f29
 			/* we have a full line, chop potential newline and turn into ldif */
7c7f29
 			if( buf[curlen-1] == '\n' )
7c7f29
diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c
7c7f29
index 1f846d0..ddfaf6c 100644
7c7f29
--- a/ldap/servers/slapd/tools/mmldif.c
7c7f29
+++ b/ldap/servers/slapd/tools/mmldif.c
7c7f29
@@ -766,8 +766,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
7c7f29
             while (*vptr == ' ') vptr++; /* skip optional spaces */
7c7f29
             b64 = initDec64((unsigned char *)att->value, 0x20000);
7c7f29
             if (Dec64(b64, (unsigned char *) vptr)) {
7c7f29
-                LDAPDebug(LDAP_DEBUG_TRACE, "%s\n invalid input line\n", 
7c7f29
-			  line, 0, 0);
7c7f29
+                LDAPDebug(LDAP_DEBUG_TRACE, "%s\n invalid input line\n", line, 0, 0);
7c7f29
                 continue;       /* invalid line, but we'll just skip it */
7c7f29
             }
7c7f29
             toolong = FALSE;
7c7f29
@@ -775,7 +774,11 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
7c7f29
                 lookahead = fgetc(edf1->fp);
7c7f29
                 if (lookahead != ' ')
7c7f29
                     break;
7c7f29
-                (void)fgets(line, sizeof(line), edf1->fp);
7c7f29
+                line[0] = '\0';
7c7f29
+                if (NULL == fgets(line, sizeof(line), edf1->fp)) {
7c7f29
+                    LDAPDebug0Args(LDAP_DEBUG_TRACE, "readrec: failed to read line\n");
7c7f29
+                    break;
7c7f29
+                }
7c7f29
                 len = strlen(line);
7c7f29
                 for (lptr = line+len-1; len; len--, lptr--) {
7c7f29
                     if ((*lptr != '\n') && (*lptr != '\r'))
7c7f29
@@ -785,16 +788,14 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
7c7f29
                 rc = Dec64(b64, (unsigned char *)line);
7c7f29
                 if (rc == -1)
7c7f29
                 {
7c7f29
-                    LDAPDebug(LDAP_DEBUG_TRACE, 
7c7f29
-			      "%s\n invalid input line\n", line, 0, 0);
7c7f29
+                    LDAPDebug(LDAP_DEBUG_TRACE, "%s\n invalid input line\n", line, 0, 0);
7c7f29
                     continue;   /* invalid line, but we'll just skip it */
7c7f29
                 }
7c7f29
 
7c7f29
                 if (rc) {
7c7f29
                     if (!toolong) {
7c7f29
                         toolong = TRUE;
7c7f29
-                        LDAPDebug(LDAP_DEBUG_TRACE, 
7c7f29
-				  "%s\n line too long\n", line, 0, 0);
7c7f29
+                        LDAPDebug(LDAP_DEBUG_TRACE, "%s\n line too long\n", line, 0, 0);
7c7f29
                     }
7c7f29
                     continue;
7c7f29
                 }
7c7f29
@@ -813,7 +814,10 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
7c7f29
                 lookahead = fgetc(edf1->fp);
7c7f29
                 if (lookahead != ' ')
7c7f29
                     break;
7c7f29
-                (void)fgets(line, sizeof(line), edf1->fp);
7c7f29
+                if (NULL == fgets(line, sizeof(line), edf1->fp)) {
7c7f29
+                    LDAPDebug0Args(LDAP_DEBUG_TRACE, "readrec: failed to read line\n");
7c7f29
+                    break;
7c7f29
+                }
7c7f29
                 len = strlen(line);
7c7f29
                 for (lptr = line+len-1; len; len--, lptr--) {
7c7f29
                     if ((*lptr != '\n') && (*lptr != '\r'))
7c7f29
diff --git a/ldap/servers/slapd/util.c b/ldap/servers/slapd/util.c
7c7f29
index a5327d1..1ebdf2e 100644
7c7f29
--- a/ldap/servers/slapd/util.c
7c7f29
+++ b/ldap/servers/slapd/util.c
7c7f29
@@ -1592,7 +1592,9 @@ int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size
7c7f29
             return 1;
7c7f29
         }
7c7f29
         while (! feof(f)) {
7c7f29
-            fgets(s, 79, f);
7c7f29
+            if (!fgets(s, 79, f)) {
7c7f29
+                break; /* error or eof */
7c7f29
+            }
7c7f29
             if (feof(f)) {
7c7f29
                 break;
7c7f29
             }
7c7f29
@@ -1614,8 +1616,9 @@ int util_info_sys_pages(size_t *pagesize, size_t *pages, size_t *procpages, size
7c7f29
             return 1;
7c7f29
         }
7c7f29
         while (! feof(fm)) {
7c7f29
-            fgets(s, 79, fm);
7c7f29
-            /* Is this really needed? */
7c7f29
+            if (!fgets(s, 79, fm)) {
7c7f29
+                break; /* error or eof */
7c7f29
+            }
7c7f29
             if (feof(fm)) {
7c7f29
                 break;
7c7f29
             }
7c7f29
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
7c7f29
index 3f96627..ea5050b 100644
7c7f29
--- a/ldap/servers/snmp/main.c
7c7f29
+++ b/ldap/servers/snmp/main.c
7c7f29
@@ -44,7 +44,7 @@ main (int argc, char *argv[]) {
7c7f29
     netsnmp_log_handler *log_hdl = NULL;
7c7f29
     int                 c, log_level = LOG_WARNING;
7c7f29
     struct stat         logdir_s;
7c7f29
-    pid_t               child_pid;
7c7f29
+    pid_t               child_pid = 0;
7c7f29
     FILE                *pid_fp;
7c7f29
 
7c7f29
     /* Load options */
7c7f29
@@ -74,7 +74,11 @@ main (int argc, char *argv[]) {
7c7f29
 
7c7f29
     /* check if we're already running as another process */
7c7f29
     if ((pid_fp = fopen(pidfile, "r")) != NULL) {
7c7f29
-        fscanf(pid_fp, "%d", &child_pid);
7c7f29
+        int rc = fscanf(pid_fp, "%d", &child_pid);
7c7f29
+        if ((rc == 0) || (rc == EOF)) {
7c7f29
+            printf("ldap-agent: Failed to get pid from %s\n", pidfile);
7c7f29
+            exit(1);
7c7f29
+        }
7c7f29
         fclose(pid_fp);
7c7f29
         if (kill(child_pid, SIGUSR1) == 0) {
7c7f29
             printf("ldap-agent: Already running as pid %d!\n", child_pid);
7c7f29
@@ -145,6 +149,7 @@ main (int argc, char *argv[]) {
7c7f29
     /* run as a daemon */
7c7f29
     if (netsnmp_daemonize(0, 0)) {
7c7f29
         int i;
7c7f29
+        int rc;
7c7f29
 
7c7f29
         /* sleep to allow pidfile to be created by child */
7c7f29
         for (i=0; i < 3; i++) {
7c7f29
@@ -159,7 +164,11 @@ main (int argc, char *argv[]) {
7c7f29
             exit(1);
7c7f29
         }
7c7f29
 
7c7f29
-        fscanf(pid_fp, "%d", &child_pid);
7c7f29
+        rc = fscanf(pid_fp, "%d", &child_pid);
7c7f29
+        if ((rc == 0) || (rc == EOF)) {
7c7f29
+            printf("ldap-agent: Failed to get pid from %s\n", pidfile);
7c7f29
+            exit(1);
7c7f29
+        }
7c7f29
         fclose(pid_fp);
7c7f29
         printf("ldap-agent: Started as pid %d\n", child_pid);
7c7f29
         exit(0);
7c7f29
diff --git a/lib/base/file.cpp b/lib/base/file.cpp
7c7f29
index 8c9274a..ad4333e 100644
7c7f29
--- a/lib/base/file.cpp
7c7f29
+++ b/lib/base/file.cpp
7c7f29
@@ -38,7 +38,6 @@ extern "C" char *nscperror_lookup(int err);
7c7f29
 /* PRFileDesc * SYS_ERROR_FD = NULL; */
7c7f29
 
7c7f29
 const int errbuf_size = 256;
7c7f29
-const unsigned int LOCKFILERANGE=0x7FFFFFFF;
7c7f29
 PRLock *_atomic_write_lock = NULL;
7c7f29
 
7c7f29
 /* --------------------------------- stat --------------------------------- */
7c7f29
diff --git a/lib/base/fsmutex.cpp b/lib/base/fsmutex.cpp
7c7f29
index e8f2aff..a0e30fd 100644
7c7f29
--- a/lib/base/fsmutex.cpp
7c7f29
+++ b/lib/base/fsmutex.cpp
7c7f29
@@ -85,11 +85,15 @@ fsmutex_init(char *name, int number, int flags)
7c7f29
 NSAPI_PUBLIC void 
7c7f29
 fsmutex_setowner(FSMUTEX fsm, uid_t uid, gid_t gid)
7c7f29
 {
7c7f29
-    if(!geteuid())
7c7f29
-        (void) chown( ((fsmutex_s *)fsm)->id, uid, gid);
7c7f29
+    if(!geteuid()) {
7c7f29
+        int rc = chown( ((fsmutex_s *)fsm)->id, uid, gid);
7c7f29
+        PR_ASSERT(rc == 0);
7c7f29
+        if (rc != 0 ) {
7c7f29
+            return; /* just to suppress compiler warning... */
7c7f29
+        }
7c7f29
+    }
7c7f29
 }
7c7f29
 
7c7f29
-
7c7f29
 /* -------------------------- fsmutex_terminate --------------------------- */
7c7f29
 
7c7f29
 static void 
7c7f29
-- 
7c7f29
2.4.11
7c7f29