aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kerrisk <mtk.manpages@gmail.com>2013-12-30 20:53:19 +1300
committerMichael Kerrisk <mtk.manpages@gmail.com>2014-01-02 11:49:15 +1300
commitaefd6f899dfa38ccb324cb8096fb6709eb4754db (patch)
tree061deb1b10f8f8e7a8916cf8e6990b0c6c1db8ee
parentb0e6462a0bedf1e291656bbd20ba74105f7adfbe (diff)
downloadman-pages-aefd6f899dfa38ccb324cb8096fb6709eb4754db.tar.gz
select_tut.2, dlopen.3, err.3, printf.3: Stylistic changes to code example
For ease of reading, don't embed assignments inside if(). Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
-rw-r--r--man2/select_tut.28
-rw-r--r--man3/dlopen.35
-rw-r--r--man3/err.314
-rw-r--r--man3/printf.38
4 files changed, 22 insertions, 13 deletions
diff --git a/man2/select_tut.2 b/man2/select_tut.2
index 1ca5d785d9..51ee6ce01f 100644
--- a/man2/select_tut.2
+++ b/man2/select_tut.2
@@ -29,7 +29,7 @@
.\" various other changes
.\" 2008-01-26, mtk, substantial changes and rewrites
.\"
-.TH SELECT_TUT 2 2012-08-03 "Linux" "Linux Programmer's Manual"
+.TH SELECT_TUT 2 2013-12-30 "Linux" "Linux Programmer's Manual"
.SH NAME
select, pselect, FD_CLR, FD_ISSET, FD_SET, FD_ZERO \-
synchronous I/O multiplexing
@@ -557,7 +557,8 @@ listen_socket(int listen_port)
int s;
int yes;
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) {
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s == \-1) {
perror("socket");
return \-1;
}
@@ -587,7 +588,8 @@ connect_socket(int connect_port, char *address)
struct sockaddr_in a;
int s;
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) == \-1) {
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s == \-1) {
perror("socket");
close(s);
return \-1;
diff --git a/man3/dlopen.3 b/man3/dlopen.3
index 8d6f80e06c..dd54120cc0 100644
--- a/man3/dlopen.3
+++ b/man3/dlopen.3
@@ -32,7 +32,7 @@
.\" Modified by Walter Harms: dladdr, dlvsym
.\" Modified by Petr Baudis <pasky@suse.cz>, 2008-12-04: dladdr caveat
.\"
-.TH DLOPEN 3 2008-12-06 "Linux" "Linux Programmer's Manual"
+.TH DLOPEN 3 2013-12-30 "Linux" "Linux Programmer's Manual"
.SH NAME
dladdr, dlclose, dlerror, dlopen, dlsym, dlvsym \- programming interface to
dynamic linking loader
@@ -476,7 +476,8 @@ main(int argc, char **argv)
*(void **) (&cosine) = dlsym(handle, "cos");
.\" But in fact "gcc -O2 -Wall" will complain about the preceding cast.
- if ((error = dlerror()) != NULL) {
+ error = dlerror();
+ if (error != NULL) {
fprintf(stderr, "%s\en", error);
exit(EXIT_FAILURE);
}
diff --git a/man3/err.3 b/man3/err.3
index 0f4e07dca8..783d60aa7a 100644
--- a/man3/err.3
+++ b/man3/err.3
@@ -36,7 +36,7 @@
.\"
.\" 2011-09-10, mtk, Converted from mdoc to man macros
.\"
-.TH ERR 3 2012-03-15 "Linux" "Linux Programmer's Manual"
+.TH ERR 3 2013-12-30 "Linux" "Linux Programmer's Manual"
.SH NAME
err, verr, errx, verrx, warn, vwarn, warnx, vwarnx \- formatted error messages
.SH SYNOPSIS
@@ -122,9 +122,11 @@ information string and exit:
.in +4n
.nf
-if ((p = malloc(size)) == NULL)
+p = malloc(size);
+if (p == NULL)
err(1, NULL);
-if ((fd = open(file_name, O_RDONLY, 0)) == \-1)
+fd = open(file_name, O_RDONLY, 0);
+if (fd == \-1)
err(1, "%s", file_name);
.fi
.in
@@ -142,10 +144,12 @@ Warn of an error:
.in +4n
.nf
-if ((fd = open(raw_device, O_RDONLY, 0)) == \-1)
+fd = open(raw_device, O_RDONLY, 0);
+if (fd == \-1)
warnx("%s: %s: trying the block device",
raw_device, strerror(errno));
-if ((fd = open(block_device, O_RDONLY, 0)) == \-1)
+fd = open(block_device, O_RDONLY, 0);
+if (fd == \-1)
err(1, "%s", block_device);
.fi
.in
diff --git a/man3/printf.3 b/man3/printf.3
index 12373f1ee7..79cabf6a12 100644
--- a/man3/printf.3
+++ b/man3/printf.3
@@ -31,7 +31,7 @@
.\" 2000-07-26 jsm28@hermes.cam.ac.uk - three small fixes
.\" 2000-10-16 jsm28@hermes.cam.ac.uk - more fixes
.\"
-.TH PRINTF 3 2013-09-04 "GNU" "Linux Programmer's Manual"
+.TH PRINTF 3 2013-12-30 "GNU" "Linux Programmer's Manual"
.SH NAME
printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf,
vsnprintf \- formatted output conversion
@@ -1043,7 +1043,8 @@ make_message(const char *fmt, ...)
char *p, *np;
va_list ap;
- if ((p = malloc(size)) == NULL)
+ p = malloc(size);
+ if (p == NULL)
return NULL;
while (1) {
@@ -1071,7 +1072,8 @@ make_message(const char *fmt, ...)
size = n + 1; /* Precisely what is needed */
- if ((np = realloc (p, size)) == NULL) {
+ np = realloc(p, size);
+ if (np == NULL) {
free(p);
return NULL;
} else {