[PATCH 0/5] trivial compile warning fixes

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/5] trivial compile warning fixes

Carlo Marcelo Arenas Belon

The following series fixes a series of trivial (and harmless) compilation warnings in trunk

  PATCH 1/5: confuse: ensure _GNU_SOURCE is defined before any included header
  PATCH 2/5: confuse: remove unneeded static input() function from generated code
  PATCH 3/5: examples: include definition for free() to avoid intrinsic
  PATCH 4/5: examples: match format to data type width in simple.c
  PATCH 5/5: confuse: match sign for parsed octal and hexadecimal input

It has been tested in linux amd64 and x86 with gcc 4.3 (fedora) and gcc 4.1 (gentoo)
but it should be safe everywhere else.

Carlo


_______________________________________________
Confuse-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/confuse-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 1/5] confuse: ensure _GNU_SOURCE is defined before any included header

Carlo Marcelo Arenas Belon

avoids the following warning because of an undefined strndup :

  confuse.c: In function ‘cfg_getopt’:
  confuse.c:147: warning: implicit declaration of function ‘strndup’
  confuse.c:147: warning: incompatible implicit declaration of built-in function ‘strndup’
  confuse.c: In function ‘cfg_getopt_array’:
  confuse.c:1580: warning: incompatible implicit declaration of built-in function ‘strndup’

Signed-off-by: Carlo Marcelo Arenas Belon <[hidden email]>
---
 src/confuse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/src/confuse.c b/src/confuse.c
index e63ab2e..003d0b9 100644
--- a/src/confuse.c
+++ b/src/confuse.c
@@ -18,8 +18,8 @@
 # include <config.h>
 #endif
 
-#include <sys/types.h>
 #define _GNU_SOURCE
+#include <sys/types.h>
 #include <string.h>
 #include <stdlib.h>
 #include <assert.h>

_______________________________________________
Confuse-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/confuse-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/5] confuse: remove unneeded static input() function from generated code

Carlo Marcelo Arenas Belon

avoids the following warning when compiled with gcc >= 4.3 :

  lexer.c:1637: warning: ‘input’ defined but not used

Signed-off-by: Carlo Marcelo Arenas Belon <[hidden email]>
---
 src/lexer.l |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)


diff --git a/src/lexer.l b/src/lexer.l
index 6c1e70b..aff7f6f 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -36,6 +36,12 @@
 #endif
 #define N_(str) str
 
+/*
+ * Prevent compilation of static input() function in generated code
+ * This function is never used but GCC 4.3 will warn about it.
+ */
+#define YY_NO_INPUT
+
 typedef char * YYSTYPE;
 extern YYSTYPE cfg_yylval;
 

_______________________________________________
Confuse-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/confuse-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 3/5] examples: include definition for free() to avoid intrinsic

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon

avoids the following warning when compiled with gcc >= 4.3

  simple.c: In function ‘main’:
  simple.c:63: warning: incompatible implicit declaration of built-in function ‘free’

Signed-off-by: Carlo Marcelo Arenas Belon <[hidden email]>
---
 examples/simple.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)


diff --git a/examples/simple.c b/examples/simple.c
index 166486b..2d8ee59 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -1,4 +1,5 @@
 #include <string.h>
+#include <stdlib.h>
 #include "confuse.h"
 
 int main(void)

_______________________________________________
Confuse-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/confuse-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 4/5] examples: match format to data type width in simple.c

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon

avoids the following warning from printing "debug" simple variable

  simple.c:42: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘long int’

Signed-off-by: Carlo Marcelo Arenas Belon <[hidden email]>
---
 examples/simple.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


diff --git a/examples/simple.c b/examples/simple.c
index 2d8ee59..9f47ec7 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -39,7 +39,7 @@ int main(void)
     printf("verbose: %s\n", verbose ? "true" : "false");
     printf("server: %s\n", server);
     printf("username: %s\n", username);
-    printf("debug: %d\n", debug);
+    printf("debug: %ld\n", debug);
     printf("delay: %G\n", delay);
 
     printf("setting username to 'foo'\n");

_______________________________________________
Confuse-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/confuse-devel
Reply | Threaded
Open this post in threaded view
|

[PATCH 5/5] confuse: match sign for parsed octal and hexadecimal input

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon

as shown by the following warning :

  lexer.l: In function ‘cfg_yylex’:
  lexer.l:142: warning: format ‘%o’ expects type ‘unsigned int *’, but argument 3 has type ‘int *’
  lexer.l:155: warning: format ‘%x’ expects type ‘unsigned int *’, but argument 3 has type ‘int *’

Signed-off-by: Carlo Marcelo Arenas Belon <[hidden email]>
---
 src/lexer.l |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


diff --git a/src/lexer.l b/src/lexer.l
index aff7f6f..1e0fa91 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -138,7 +138,7 @@ static YY_BUFFER_STATE string_scan_state = 0;
     cfg->line++;
 }
 <dq_str>\\[0-7]{1,3} {  /* octal escape sequence */
-    int result;
+    unsigned int result;
     sscanf(yytext + 1, "%o", &result);
     if(result > 0xFF) {
         cfg_error(cfg, _("invalid octal number '%s'"), yytext);
@@ -151,7 +151,7 @@ static YY_BUFFER_STATE string_scan_state = 0;
     return 0;
 }
 <dq_str>"\\x"[0-9A-Fa-f]{1,2} { /* hexadecimal escape sequence */
-    int result;
+    unsigned int result;
     sscanf(yytext + 2, "%x", &result);
     qputc(result);
 }

_______________________________________________
Confuse-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/confuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 0/5] trivial compile warning fixes

Martin Hedenfalk-4
In reply to this post by Carlo Marcelo Arenas Belon
Great, I'll have a look at this soon.

        -martin

30 nov 2008 kl. 22.55 skrev Carlo Marcelo Arenas Belon:

>
> The following series fixes a series of trivial (and harmless)  
> compilation warnings in trunk
>
>  PATCH 1/5: confuse: ensure _GNU_SOURCE is defined before any  
> included header
>  PATCH 2/5: confuse: remove unneeded static input() function from  
> generated code
>  PATCH 3/5: examples: include definition for free() to avoid intrinsic
>  PATCH 4/5: examples: match format to data type width in simple.c
>  PATCH 5/5: confuse: match sign for parsed octal and hexadecimal input
>
> It has been tested in linux amd64 and x86 with gcc 4.3 (fedora) and  
> gcc 4.1 (gentoo)
> but it should be safe everywhere else.
>
> Carlo
>
>
> _______________________________________________
> Confuse-devel mailing list
> [hidden email]
> http://lists.nongnu.org/mailman/listinfo/confuse-devel



_______________________________________________
Confuse-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/confuse-devel