From 6afad7276402a90b3776ddeefb205978af42fdab Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Wed, 2 Aug 2017 23:25:13 +0200 Subject: Delete more assignments in if conditions. Based on below coccinelle script with a bad transformation fixed up manually. @if1@ expression E, F, G; binary operator X; statement S; @@ - if ((E = F) X G) + E = F; + if (E X G) S @if2@ expression E, F, G; binary operator X; statement S; @@ - if (G X (E = F)) + E = F; + if (E X G) S @if3@ expression E, F; statement S; @@ - if (!(E = F)) + E = F; + if (!E) S @if4@ expression E, F; statement S; @@ - if ((E = F)) + E = F; + if (E) S Signed-off-by: Ralf Baechle --- ax25/access.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'ax25/access.c') diff --git a/ax25/access.c b/ax25/access.c index 2ecbb1d..05d3375 100644 --- a/ax25/access.c +++ b/ax25/access.c @@ -210,7 +210,8 @@ static void write_example_passwd(char *pwfile, char pwlocation, return; fchown(i, (pwlocation == SYSTEMPW ? 0 : pw->pw_uid), (pwlocation == SYSTEMPW ? 0 : pw->pw_gid)); close(i); - if ( ! (f = fopen(pwfile, "w")) ) + f = fopen(pwfile, "w"); + if (!f) return; fprintf(f, "# %s Password file for axspawn\n", (pwlocation == SYSTEMPW ? "System" : "User")); if (pwlocation == SYSTEMPW) { @@ -255,7 +256,8 @@ char *read_pwd (struct passwd *pw, int *pwtype) } if (!S_ISREG(statbuf.st_mode) || (statbuf.st_mode & (S_IROTH | S_IWOTH))) continue; - if ( !(f = fopen(pwfile, "r")) ) + f = fopen(pwfile, "r"); + if (!f) continue; } else { if (only_systempw) @@ -300,7 +302,8 @@ char *read_pwd (struct passwd *pw, int *pwtype) write_ax25(buf, strlen(buf), 1); /* go on.. if user takes no action, he always gets this message */ } - if ( !(f = fopen(pwfile, "r")) ) + f = fopen(pwfile, "r"); + if (!f) goto end; } @@ -321,7 +324,8 @@ char *read_pwd (struct passwd *pw, int *pwtype) } goto end; } - if ((p = strchr(buf, '\n'))) + p = strchr(buf, '\n'); + if (p) *p = 0; if (!*buf || isspace(*buf & 0xff)) continue; @@ -332,7 +336,8 @@ char *read_pwd (struct passwd *pw, int *pwtype) only_systempw = 1; continue; } - if (!(p = strchr(buf, ':'))) + p = strchr(buf, ':'); + if (!p) continue; *p++ = 0; if (strcmp(pw->pw_name, buf)) @@ -345,7 +350,8 @@ char *read_pwd (struct passwd *pw, int *pwtype) if (!Strcasecmp(p_buf, "unix")) { pass = p_buf; } else { - if (!(pass = strchr(p_buf, ':'))) + pass = strchr(p_buf, ':'); + if (!pass) continue; *pass++ = 0; } -- cgit v1.2.3