Skip to contentSkip to conversation

server/server.c (net_write_port): Don't ignore write error.

PATCH In review Jim Meyering 2 participants 3 messages Sep 23, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 server/server.c (net_write_port): Don't ignore write error.

Better safe than sorry...
Unreported write failures can be unpleasant.
I fixed the one below so that a failure indication can propagate up the call tree. You might also want to report the failure to stderr.

I let my editor automatically update the copyright date and remove trailing spaces.
If you'd rather separate those from the fix, let me know and I can adjust and resend.

From abe4be09fea8194fe0c4187c20ebaa45822c839c Mon Sep 17 00:00:00 2001
From: Jim Meyering <[email protected]>
Date: Thu, 23 Sep 2010 09:38:24 +0200
Subject: [PATCH tabled] server/server.c (net_write_port): Don't ignore write error.

---
 server/server.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
server/server.c +9 -7
index 7a9fb7a..3398026 100644
@@ -1,6 +1,6 @@
 
 /*
- * Copyright 2008-2009 Red Hat, Inc.
+ * Copyright 2008-2010 Red Hat, Inc.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -1613,7 +1613,7 @@ void cld_update_cb(void)
  * server, the management of nodes is not in storage.c, which deals
  * with the interface to Chunk and little more.
  *
- * We don't even bother with registering this callback, just call it by name. 
+ * We don't even bother with registering this callback, just call it by name.
  *
  * The return value is used to re-arm storage rescan mechanism.
  */
@@ -1847,9 +1847,12 @@ static int net_write_port(const char *port_file,
 		       port_file, strerror(rc));
 		return -rc;
 	}
-	fprintf(portf, "%s:%s\n", tabled_srv.ourhost, port);
-	fclose(portf);
-	return 0;
+	if (fprintf(portf, "%s:%s\n", tabled_srv.ourhost, port) < 0) {
+		rc = errno;
+		fclose(portf);
+		return -rc;
+	}
+	return fclose(portf) ? -errno : 0;
 }
 
 /*
@@ -1959,7 +1962,7 @@ static int net_open_known(const char *portstr, bool is_status)
 			continue;
 
 		rc = net_open_socket(res->ai_family, res->ai_socktype,
-				     res->ai_protocol, 
+				     res->ai_protocol,
 				     res->ai_addrlen, res->ai_addr, is_status);
 		if (rc < 0)
 			goto err_out;
@@ -2348,4 +2351,3 @@ err_out:
 		closelog();
 	return rc;
 }
-
Signature · 1 line
1.7.3.234.g7bba3
#1 lore raw
Quoted 10 lines · Jim Meyering

Better safe than sorry...
Unreported write failures can be unpleasant.
I fixed the one below so that a failure indication can propagate up the call tree. You might also want to report the failure to stderr.

I let my editor automatically update the copyright date and remove trailing spaces.
If you'd rather separate those from the fix, let me know and I can adjust and resend.

Patch applied, thanks.

The typical preference is to receive whitespace and other cosmetic changes in a separate patch, thereby highlighting the functional changes.

But we're not so strict here that I would reject an otherwise useful patch...

Also FWIW, we're not very strict about reproducing the GCC-ish (GNU-ish?) style of "$FILENAME ($FUNCTION):" in each changelog -- though you're certainly welcome to continue, if that's your preference.

Given that "git show $COMMIT" will give you filename and per-diff-chunk function names, reproducing that in the git changelog entry seems somewhat redundant. A simple, English-language summary of the change is fine. Just a style tip, though, feel free to ignore! :)

Jeff

#2 lore raw
Quoted 18 lines · Jeff Garzik
Quoted 10 lines · Jim Meyering

Better safe than sorry...
Unreported write failures can be unpleasant.
I fixed the one below so that a failure indication can propagate up the call tree. You might also want to report the failure to stderr.

I let my editor automatically update the copyright date and remove trailing spaces.
If you'd rather separate those from the fix, let me know and I can adjust and resend.

Patch applied, thanks.

The typical preference is to receive whitespace and other cosmetic changes in a separate patch, thereby highlighting the functional changes.

Quoted 7 lines

But we're not so strict here that I would reject an otherwise useful patch...

Also FWIW, we're not very strict about reproducing the GCC-ish (GNU-ish?) style of "$FILENAME ($FUNCTION):" in each changelog -- though you're certainly welcome to continue, if that's your preference.

Yes, the function name is added automatically when I hit C-4-a. Easy to omit from now on.

Quoted 5 lines

Given that "git show $COMMIT" will give you filename and per-diff-chunk function names, reproducing that in the git changelog entry seems somewhat redundant. A simple, English-language summary of the change is fine. Just a style tip, though, feel free to ignore! :)

Tips are always most welcome. Thanks.