bug-patch
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-patch] [patch] use fputs() in simple fprintf() situations


From: Mike Frysinger
Subject: [bug-patch] [patch] use fputs() in simple fprintf() situations
Date: Sun, 15 Mar 2009 19:52:38 -0400
User-agent: KMail/1.11.1 (Linux/2.6.28; KDE/4.2.1; x86_64; ; )

there are a few places where fprintf() is used to write out a buffer.  gcc may
warn on this because no format string is used.  so switching to fputs() avoids
this.  for example:
patch.c: In function ‘apply_hunk’:
patch.c:1017: warning: format not a string literal and no format arguments
patch.c:1036: warning: format not a string literal and no format arguments
patch.c:1084: warning: format not a string literal and no format arguments
patch.c:1103: warning: format not a string literal and no format arguments
patch.c:1121: warning: format not a string literal and no format arguments
patch.c:1140: warning: format not a string literal and no format arguments
-mike

diff --git a/patch.c b/patch.c
index 9e04daf..45928ee 100644
--- a/patch.c
+++ b/patch.c
@@ -1014,7 +1014,7 @@ apply_hunk (struct outstate *outstate, LINENUM where)
                    def_state = IN_IFNDEF;
                }
                else if (def_state == IN_IFDEF) {
-                   fprintf (fp, outstate->after_newline + else_defined);
+                   fputs (outstate->after_newline + else_defined, fp);
                    def_state = IN_ELSE;
                }
                if (ferror (fp))
@@ -1033,7 +1033,7 @@ apply_hunk (struct outstate *outstate, LINENUM where)
                return false;
            if (R_do_defines) {
                if (def_state == IN_IFNDEF) {
-                   fprintf (fp, outstate->after_newline + else_defined);
+                   fputs (outstate->after_newline + else_defined, fp);
                    def_state = IN_ELSE;
                }
                else if (def_state == OUTSIDE) {
@@ -1081,7 +1081,7 @@ apply_hunk (struct outstate *outstate, LINENUM where)
            while (pch_char (old) == '!');
 
            if (R_do_defines) {
-               fprintf (fp, outstate->after_newline + else_defined);
+               fputs (outstate->after_newline + else_defined, fp);
                if (ferror (fp))
                  write_fatal ();
                def_state = IN_ELSE;
@@ -1100,7 +1100,7 @@ apply_hunk (struct outstate *outstate, LINENUM where)
            old++;
            new++;
            if (R_do_defines && def_state != OUTSIDE) {
-               fprintf (fp, outstate->after_newline + end_defined);
+               fputs (outstate->after_newline + end_defined, fp);
                if (ferror (fp))
                  write_fatal ();
                outstate->after_newline = true;
@@ -1118,7 +1118,7 @@ apply_hunk (struct outstate *outstate, LINENUM where)
                def_state = IN_IFDEF;
            }
            else if (def_state == IN_IFNDEF) {
-               fprintf (fp, outstate->after_newline + else_defined);
+               fputs (outstate->after_newline + else_defined, fp);
                def_state = IN_ELSE;
            }
            if (ferror (fp))
@@ -1137,7 +1137,7 @@ apply_hunk (struct outstate *outstate, LINENUM where)
        while (new <= pat_end && pch_char (new) == '+');
     }
     if (R_do_defines && def_state != OUTSIDE) {
-       fprintf (fp, outstate->after_newline + end_defined);
+       fputs (outstate->after_newline + end_defined, fp);
        if (ferror (fp))
          write_fatal ();
        outstate->after_newline = true;

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]