silence clang warnings: add an extra pair of parentheses and stop
authornaddy <naddy@openbsd.org>
Wed, 26 Apr 2017 21:25:43 +0000 (21:25 +0000)
committernaddy <naddy@openbsd.org>
Wed, 26 Apr 2017 21:25:43 +0000 (21:25 +0000)
passing empty format strings to printf-family functions; ok millert@

bin/ed/glbl.c
bin/ed/io.c
bin/ed/main.c

index b4cb41f..27ebc0c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: glbl.c,v 1.18 2016/03/22 17:58:28 mmcc Exp $  */
+/*     $OpenBSD: glbl.c,v 1.19 2017/04/26 21:25:43 naddy Exp $ */
 /*     $NetBSD: glbl.c,v 1.2 1995/03/21 09:04:41 cgd Exp $     */
 
 /* glob.c: This file contains the global command routines for the ed line
@@ -67,7 +67,7 @@ build_active_list(int isgcmd)
                        return ERR;
                if (isbinary)
                        NUL_TO_NEWLINE(s, lp->len);
-               if (!regexec(pat, s, 0, NULL, 0) == isgcmd &&
+               if ((!regexec(pat, s, 0, NULL, 0)) == isgcmd &&
                    set_active_node(lp) < 0)
                        return ERR;
        }
index 2a81d2a..13e2c58 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: io.c,v 1.19 2016/03/22 17:58:28 mmcc Exp $    */
+/*     $OpenBSD: io.c,v 1.20 2017/04/26 21:25:43 naddy Exp $   */
 /*     $NetBSD: io.c,v 1.2 1995/03/21 09:04:43 cgd Exp $       */
 
 /* io.c: This file contains the i/o routines for the ed line editor */
@@ -63,7 +63,8 @@ read_file(char *fn, int n)
                seterrmsg("cannot close input file");
                return ERR;
        }
-       fprintf(stderr, !scripted ? "%d\n" : "", size);
+       if (!scripted)
+               fprintf(stderr, "%d\n", size);
        return current_addr - n;
 }
 
@@ -164,7 +165,8 @@ write_file(char *fn, char *mode, int n, int m)
                seterrmsg("cannot close output file");
                return ERR;
        }
-       fprintf(stderr, !scripted ? "%d\n" : "", size);
+       if (!scripted)
+               fprintf(stderr, "%d\n", size);
        return n ? m - n + 1 : 0;
 }
 
index 33c3550..3ddf399 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: main.c,v 1.59 2017/01/03 20:24:29 tb Exp $    */
+/*     $OpenBSD: main.c,v 1.60 2017/04/26 21:25:43 naddy Exp $ */
 /*     $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $     */
 
 /* main.c: This file contains the main control and user-interface routines
@@ -218,9 +218,10 @@ top:
                                fputs("?\n", stderr);
                                seterrmsg("warning: file modified");
                                if (!interactive) {
-                                       fprintf(stderr, garrulous ?
-                                           "script, line %d: %s\n" :
-                                           "", lineno, errmsg);
+                                       if (garrulous)
+                                               fprintf(stderr,
+                                                   "script, line %d: %s\n",
+                                                   lineno, errmsg);
                                        quit(2);
                                }
                                clearerr(stdin);
@@ -252,28 +253,30 @@ top:
                        fputs("?\n", stderr);           /* give warning */
                        seterrmsg("warning: file modified");
                        if (!interactive) {
-                               fprintf(stderr, garrulous ?
-                                   "script, line %d: %s\n" :
-                                   "", lineno, errmsg);
+                               if (garrulous)
+                                       fprintf(stderr,
+                                           "script, line %d: %s\n",
+                                           lineno, errmsg);
                                quit(2);
                        }
                        break;
                case FATAL:
-                       if (!interactive)
-                               fprintf(stderr, garrulous ?
-                                   "script, line %d: %s\n" : "",
-                                   lineno, errmsg);
-                       else
-                               fprintf(stderr, garrulous ? "%s\n" : "",
-                                   errmsg);
+                       if (!interactive) {
+                               if (garrulous)
+                                       fprintf(stderr,
+                                           "script, line %d: %s\n",
+                                           lineno, errmsg);
+                       } else if (garrulous)
+                               fprintf(stderr, "%s\n", errmsg);
                        quit(3);
                        break;
                default:
                        fputs("?\n", stderr);
                        if (!interactive) {
-                               fprintf(stderr, garrulous ?
-                                   "script, line %d: %s\n" : "",
-                                   lineno, errmsg);
+                               if (garrulous)
+                                       fprintf(stderr,
+                                           "script, line %d: %s\n",
+                                           lineno, errmsg);
                                quit(2);
                        }
                        break;