Wanted to give distcc-trunk a shot, but building it on my ubuntu box
ended up with a number of warnings. Trivial patch attached.

Regards,
Andrey
### Eclipse Workspace Patch 1.0
#P distcc-trunk
Index: src/stats.c
===================================================================
--- src/stats.c	(revision 709)
+++ src/stats.c	(working copy)
@@ -103,9 +103,10 @@
 void dcc_stats_event(enum stats_e e) {
     if (arg_stats) {
         struct statsdata sd;
+        int err;
         memset(&sd, 0, sizeof(sd));
         sd.type = e;
-        write(dcc_statspipe[1], &sd, sizeof(sd));
+        err = write(dcc_statspipe[1], &sd, sizeof(sd));
     }
 }
 
@@ -116,6 +117,7 @@
 void dcc_stats_compile_ok(char *compiler, char *filename, int time_usec) {
     if (arg_stats) {
         struct statsdata sd;
+        int err;
         memset(&sd, 0, sizeof(sd));
 
         sd.type = STATS_COMPILE_OK;
@@ -123,7 +125,7 @@
         sd.time = time_usec;
         strncpy(sd.filename, filename, MAX_FILENAME_LEN);
         strncpy(sd.compiler, compiler, MAX_FILENAME_LEN);
-        write(dcc_statspipe[1], &sd, sizeof(sd));
+        err = write(dcc_statspipe[1], &sd, sizeof(sd));
     }
 }
 
@@ -303,8 +305,9 @@
                                dcc_stats.io_rate,
                                free_space_mb);
         dcc_set_nonblocking(acc_fd);
-        read(acc_fd, challenge, 1024); /* empty the receive queue */
-        write(acc_fd, reply, reply_len);
+        int err;
+        err = read(acc_fd, challenge, 1024); /* empty the receive queue */
+        err = write(acc_fd, reply, reply_len);
     }
 
     /* Don't think we need this to prevent RST anymore, since we read() now */
Index: src/srvrpc.c
===================================================================
--- src/srvrpc.c	(revision 709)
+++ src/srvrpc.c	(working copy)
@@ -87,8 +87,7 @@
 static int prepend_dir_to_name(const char *dirname, char **path)
 {
     char *buf;
-    asprintf(&buf, "%s%s", dirname, *path);
-    if (buf == NULL) {
+    if (asprintf(&buf, "%s%s", dirname, *path) < 0) {
             return EXIT_OUT_OF_MEMORY;
     }
     free(*path);
Index: src/util.c
===================================================================
--- src/util.c	(revision 709)
+++ src/util.c	(working copy)
@@ -418,6 +418,7 @@
 char *dcc_abspath(const char *path, int path_len)
 {
     static char buf[MAXPATHLEN];
+    char *ret;
     unsigned len;
     char *p, *slash;
 
@@ -425,7 +426,7 @@
         len = 0;
     else {
 #ifdef HAVE_GETCWD
-        getcwd(buf, sizeof buf);
+        ret = getcwd(buf, sizeof buf);
 #else
         getwd(buf);
 #endif
@@ -634,12 +635,12 @@
 /* Returns the number of sector read/writes since boot */
 void dcc_get_disk_io_stats(int *n_reads, int *n_writes) {
 #if defined(linux)
-    int retval;
+    int retval, res;
     int kernel26 = 1;
     FILE *f;
     int reads, writes, minor;
     char dev[100];
-    char tmp[1024];
+    char tmp[1024], *tmpp;
 
     *n_reads = 0;
     *n_writes = 0;
@@ -658,7 +659,7 @@
     }
 
     if (!kernel26) /* blast away 2 header lines in /proc/partitions */
-        fscanf(f, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s");
+        res = fscanf(f, "%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s");
 
     while (1) {
         if (kernel26)
@@ -689,7 +690,7 @@
                 break;
 #endif
             /* assume the lines aren't longer that 1024 characters */
-            fgets(tmp, 1024, f);
+            tmpp = fgets(tmp, 1024, f);
         }
     }
 
Index: src/trace.c
===================================================================
--- src/trace.c	(revision 709)
+++ src/trace.c	(working copy)
@@ -319,6 +319,7 @@
     /* NOTE NO TRAILING NUL */
     char buf[4090];
     size_t len;
+    int res;
 
     rs_format_msg(buf, sizeof buf, flags, fn, fmt, va);
 
@@ -327,7 +328,7 @@
         len = (int) sizeof buf - 2;
     strcpy(&buf[len], "\n");
 
-    (void) write(log_fd, buf, len+1);
+    res = write(log_fd, buf, len+1);
 }
 
 
Index: src/serve.c
===================================================================
--- src/serve.c	(revision 709)
+++ src/serve.c	(working copy)
@@ -431,11 +431,10 @@
                 if (argv[i] != NULL) {  /* in case of a dangling -I */
                     if (argv[i][index_of_first_filename_char] == '/') {
                         char *buf;
-                        asprintf(&buf, "%s%s%s",
+                        if (asprintf(&buf, "%s%s%s",
                                  include_option,
                                  root_dir,
-                                 argv[i] + index_of_first_filename_char);
-                        if (buf == NULL) {
+                                 argv[i] + index_of_first_filename_char) < 0) {
                             return EXIT_OUT_OF_MEMORY;
                         }
                         free(argv[i]);
@@ -544,8 +543,7 @@
         if ((ret = dcc_r_cwd(in_fd, client_side_cwd)))
             return ret;
 
-        asprintf(server_side_cwd, "%s%s", *temp_dir, *client_side_cwd);
-        if (*server_side_cwd == NULL) {
+        if (asprintf(server_side_cwd, "%s%s", *temp_dir, *client_side_cwd) < 0) {
             ret = EXIT_OUT_OF_MEMORY;
         } else if ((ret = dcc_mk_tmp_ancestor_dirs(*server_side_cwd))) {
             ; /* leave ret the way it is */
@@ -774,9 +772,11 @@
         dcc_stats_event(job_result);
     }
 
-    asprintf(&time_str, " exit:%d sig:%d core:%d ret:%d time:%dms ", WEXITSTATUS(status), WTERMSIG(status), WCOREDUMP(status), ret, time_ms);
-    dcc_job_summary_append(time_str);
-    free(time_str);
+    if (asprintf(&time_str, " exit:%d sig:%d core:%d ret:%d time:%dms ", \
+    		WEXITSTATUS(status), WTERMSIG(status), WCOREDUMP(status), ret, time_ms) > 0) {
+    	dcc_job_summary_append(time_str);
+    	free(time_str);
+    }
 
     /* append compiler and input file info */
     if (job_result == STATS_COMPILE_ERROR
Index: src/netutil.c
===================================================================
--- src/netutil.c	(revision 709)
+++ src/netutil.c	(working copy)
@@ -193,23 +193,28 @@
                            size_t UNUSED(salen),
                            char **p_buf)
 {
+	int err = 0;
     if (!sa) {
         *p_buf = strdup("NOTSOCKET");
-        return 0;
+        goto out;
     } else if (sa->sa_family == AF_INET) {
         /* The double-cast here suppresses warnings from -Wcast-align. */
         struct sockaddr_in *sain = (struct sockaddr_in *) (void *) sa;
 
-        asprintf(p_buf, "%s:%d", inet_ntoa(sain->sin_addr),
-                 ntohs(sain->sin_port));
+        if ((err = asprintf(p_buf, "%s:%d", inet_ntoa(sain->sin_addr),
+                 ntohs(sain->sin_port))) < 0)
+        	goto out;
     } else if (sa->sa_family == AF_UNIX) {
         /* NB: The word 'sun' is predefined on Solaris */
         struct sockaddr_un *sa_un = (struct sockaddr_un *) sa;
-        asprintf(p_buf, "UNIX-DOMAIN %s", sa_un->sun_path);
+        if ((err = asprintf(p_buf, "UNIX-DOMAIN %s", sa_un->sun_path)) < 0)
+        	goto out;
     } else {
-        asprintf(p_buf, "UNKNOWN-FAMILY %d", sa->sa_family);
+        if ((err = asprintf(p_buf, "UNKNOWN-FAMILY %d", sa->sa_family)) < 0)
+        	goto out;
     }
-
-    return 0;
+    err = 0;
+out:
+    return err;
 }
 #endif /* ndef ENABLE_RFC2553 */
Index: src/mon.c
===================================================================
--- src/mon.c	(revision 709)
+++ src/mon.c	(working copy)
@@ -259,7 +259,9 @@
         return 0;
     }
 
-    asprintf(&fullpath, "%s/%s", dirname, filename);
+    if ((ret = asprintf(&fullpath, "%s/%s", dirname, filename)) < 0) {
+    	return ret;
+    }
     rs_trace("process %s", fullpath);
 
     /* Remember that the file might disappear at any time, so open it
Index: src/hosts.c
===================================================================
--- src/hosts.c	(revision 709)
+++ src/hosts.c	(working copy)
@@ -157,7 +157,7 @@
 {
     char *env;
     char *path, *top;
-    int ret;
+    int err, ret;
 
     *ret_list = NULL;
     *ret_nhosts = 0;
@@ -171,7 +171,7 @@
     if ((ret = dcc_get_top_dir(&top)) == 0) {
         /* if we failed to get it, just warn */
 
-        asprintf(&path, "%s/hosts", top);
+        err = asprintf(&path, "%s/hosts", top);
         if (access(path, R_OK) == 0) {
             ret = dcc_parse_hosts_file(path, ret_list, ret_nhosts);
             free(path);
@@ -182,7 +182,7 @@
         }
     }
 
-    asprintf(&path, "%s/distcc/hosts", SYSCONFDIR);
+    err = asprintf(&path, "%s/distcc/hosts", SYSCONFDIR);
     if (access(path, R_OK) == 0) {
         ret = dcc_parse_hosts_file(path, ret_list, ret_nhosts);
         free(path);
Index: src/emaillog.c
===================================================================
--- src/emaillog.c	(revision 709)
+++ src/emaillog.c	(working copy)
@@ -90,15 +90,22 @@
   if (dcc_open_read(fname, &in_fd, &fsize))
       return 1;
 
-  write(email_fileno, begin, strlen(begin));
-  write(email_fileno, description, strlen(description));
-  write(email_fileno, "\n", 1);
+  if (write(email_fileno, begin, strlen(begin)) < (int) strlen(begin) ||
+	  write(email_fileno, description, strlen(description)) < (int) strlen(description) ||
+	  write(email_fileno, "\n", 1) < 1) {
+		  perror("write");
+		  return 1;
+  }
 
   dcc_pump_readwrite(email_fileno, in_fd, fsize);
 
-  write(email_fileno, end, strlen(end));
-  write(email_fileno, description, strlen(description));
-  write(email_fileno, "\n", 1);
+  if (write(email_fileno, end, strlen(end)) < (int) strlen(end) ||
+		  /* Really need a duplicate? */
+      write(email_fileno, description, strlen(description)) < (int) strlen(description) ||
+      write(email_fileno, "\n", 1) < 1) {
+    	  perror("write");
+    	  return 1;
+   }
 
   close(in_fd);
 
@@ -118,10 +125,16 @@
   if (should_send_email == 0) return;
   if (never_send_email) return;
 
-  asprintf(&will_send_message_to, will_send_message_format, whom_to_blame);
-  asprintf(&cant_send_message_to, cant_send_message_format, whom_to_blame);
+  if (asprintf(&will_send_message_to, will_send_message_format, whom_to_blame) < 0) {
+	  perror("asprintf");
+	  return;
+  }
+  if (asprintf(&cant_send_message_to, cant_send_message_format, whom_to_blame) < 0) {
+	  perror("asprintf");
+	  return;
+  }
 
-  rs_log_warning(will_send_message_to);
+  rs_log_warning("%s", will_send_message_to);
   free(will_send_message_to);
 
   if (email_fileno < 0) {
Index: src/dotd.c
===================================================================
--- src/dotd.c	(revision 709)
+++ src/dotd.c	(working copy)
@@ -253,6 +253,7 @@
 
         char *extension;
         char *tmp_dotd_fname;
+
         ret = dcc_scan_args(argv, &input_file, &output_file, &new_args);
         /* if .o is set, just append .d.
          * otherwise, take the basename of the input, and set the suffix to .d */
@@ -271,14 +272,12 @@
           *dotd_fname = tmp_dotd_fname;
         }
         else { /* There is no extension (or name ends with a "."). */
-          if (tmp_dotd_fname[strlen(tmp_dotd_fname) - 1] == '.')
-            asprintf(dotd_fname, "%s%s", tmp_dotd_fname, "d");
-          else
-            asprintf(dotd_fname, "%s%s", tmp_dotd_fname, ".d");
-          if (*dotd_fname == NULL) {
-            return EXIT_OUT_OF_MEMORY;
-          }
-          free(tmp_dotd_fname);
+
+            if (asprintf(dotd_fname, "%s%s", tmp_dotd_fname,
+            		tmp_dotd_fname[strlen(tmp_dotd_fname) - 1] == '.' ? "d": ".d") < 0) {
+            	return EXIT_OUT_OF_MEMORY;
+            }
+            free(tmp_dotd_fname);
         }
         return 0;
     }
__
distcc mailing list            http://distcc.samba.org/
To unsubscribe or change options:
https://lists.samba.org/mailman/listinfo/distcc

Reply via email to