]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: remove a few warning about unchecked return values in debug code
authorWilly Tarreau <w@1wt.eu>
Sun, 29 Apr 2012 12:11:38 +0000 (14:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 30 Apr 2012 09:56:30 +0000 (11:56 +0200)
There were a few unchecked write() calls in the debug code that cause
gcc 4.x to emit warnings on recent libc. We don't want to check them
as we can't make anything from the result, let's simply surround them
with an empty if statement.

Note that one of the warnings was for chdir("/") which normally cannot
fail since it follows a successful chroot (which means the perms are
necessarily there). Anyway let's move the call uppe to protect it too.

src/appsession.c
src/frontend.c
src/haproxy.c
src/proto_http.c
src/session.c

index 1d442ca2f2eaadc080143bf20b08a8246f68d8fe..ec97336e3f6873741c75e39c052fbe6df36473b3 100644 (file)
@@ -103,7 +103,7 @@ static struct task *appsession_refresh(struct task *t)
                                                */
                                                len = sprintf(trash, "appsession_refresh: cleaning up expired Session '%s' on Server %s\n", 
                                                              element->sessid, element->serverid?element->serverid:"(null)");
-                                               write(1, trash, len);
+                                               if (write(1, trash, len) < 0) /* shut gcc warning */;
                                        }
                                        /* delete the expired element from within the hash table */
                                        LIST_DEL(&element->hash_list);
index 12f55ad2b68630aa42baf93225e1b14b2e03c678..e5d847bc9c353bae7475c6eefd8c17ac40501f68 100644 (file)
@@ -181,7 +181,7 @@ int frontend_accept(struct session *s)
                        break;
                }
 
-               write(1, trash, len);
+               if (write(1, trash, len) < 0) /* shut gcc warning */;
        }
 
        if (s->fe->mode == PR_MODE_HTTP)
index d0ea713184cc406391a780606efb228a28876793..fdc6acc1374890330c2b6722161ff80f6a213099 100644 (file)
@@ -1292,14 +1292,13 @@ int main(int argc, char **argv)
 
        /* chroot if needed */
        if (global.chroot != NULL) {
-               if (chroot(global.chroot) == -1) {
+               if (chroot(global.chroot) == -1 || chdir("/") == -1) {
                        Alert("[%s.main()] Cannot chroot(%s).\n", argv[0], global.chroot);
                        if (nb_oldpids)
                                tell_old_pids(SIGTTIN);
                        protocol_unbind_all();
                        exit(1);
                }
-               chdir("/");
        }
 
        if (nb_oldpids)
index 22623c058ab092acb7ccc0d3a1a0b8e029612925..88226d19a924b06b97eb6fc706f56fd76b3698e8 100644 (file)
@@ -7347,7 +7347,7 @@ void debug_hdr(const char *dir, struct session *t, const char *start, const char
        UBOUND(max, sizeof(trash) - len - 1);
        len += strlcpy2(trash + len, start, max + 1);
        trash[len++] = '\n';
-       write(1, trash, len);
+       if (write(1, trash, len) < 0) /* shut gcc warning */;
 }
 
 /*
index e814903aabdfc0453c85750b64a47a788586166d..017ac2672c2d5365c3382733a01ac26c25088878 100644 (file)
@@ -2063,7 +2063,7 @@ struct task *process_session(struct task *t)
                                      s->uniq_id, s->be->id,
                                      (unsigned short)s->si[0].fd,
                                      (unsigned short)s->si[1].fd);
-                       write(1, trash, len);
+                       if (write(1, trash, len) < 0) /* shut gcc warning */;
                }
 
                if (s->si[0].state == SI_ST_CLO &&
@@ -2072,7 +2072,7 @@ struct task *process_session(struct task *t)
                                      s->uniq_id, s->be->id,
                                      (unsigned short)s->si[0].fd,
                                      (unsigned short)s->si[1].fd);
-                       write(1, trash, len);
+                       if (write(1, trash, len) < 0) /* shut gcc warning */;
                }
        }
 
@@ -2179,7 +2179,7 @@ struct task *process_session(struct task *t)
                len = sprintf(trash, "%08x:%s.closed[%04x:%04x]\n",
                              s->uniq_id, s->be->id,
                              (unsigned short)s->req->prod->fd, (unsigned short)s->req->cons->fd);
-               write(1, trash, len);
+               if (write(1, trash, len) < 0) /* shut gcc warning */;
        }
 
        s->logs.t_close = tv_ms_elapsed(&s->logs.tv_accept, &now);