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

[linux-lvm] avoid format-mismatch warnings on x86_64



Building from cvs, with an added -Wformat-security option in CFLAGS,
I got two warnings:

    format_text/export.c:163: warning: format not a string literal and no format arguments
    format_text/export.c:179: warning: format not a string literal and no format arguments

The following patch fixes those and adds the option to make.tmpl.in.

2007-04-26  Jim Meyering  <jim meyering net>

	* lib/format_text/export.c (_out_with_comment_file): Avoid using
	a non-literal fprintf format string.  Instead, use fputs.

Index: lib/format_text/export.c
===================================================================
RCS file: /cvs/lvm2/LVM2/lib/format_text/export.c,v
retrieving revision 1.54
diff -u -p -r1.54 export.c
--- lib/format_text/export.c	10 Nov 2006 18:24:11 -0000	1.54
+++ lib/format_text/export.c	26 Apr 2007 12:03:59 -0000
@@ -160,7 +160,7 @@ static int _out_with_comment_file(struct
 	for (i = 0; i < f->indent; i++)
 		white_space[i] = '\t';
 	white_space[i] = '\0';
-	fprintf(f->data.fp, white_space);
+	fputs(white_space, f->data.fp);
 	i = vfprintf(f->data.fp, fmt, ap);

 	if (comment) {
@@ -176,7 +176,7 @@ static int _out_with_comment_file(struct

 		while (++i < COMMENT_TAB);

-		fprintf(f->data.fp, comment);
+		fputs(comment, f->data.fp);
 	}
 	fputc('\n', f->data.fp);


Index: make.tmpl.in
===================================================================
RCS file: /cvs/lvm2/LVM2/make.tmpl.in,v
retrieving revision 1.47
diff -u -p -r1.47 make.tmpl.in
--- make.tmpl.in	11 Jan 2007 17:12:26 -0000	1.47
+++ make.tmpl.in	26 Apr 2007 12:08:30 -0000
@@ -56,7 +56,7 @@ endif

 .SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib

-CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn
+CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security

 #CFLAGS += -W -Wconversion -Wpointer-arith -Wredundant-decls -Wbad-function-cast -Wcast-qual
 #CFLAGS += -pedantic -std=gnu99


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