[PATCH 0/7] trivial compilation fixes for linux.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 0/7] trivial compilation fixes for linux.

Carlo Marcelo Arenas Belon
The following patch series consist of a list of trivial fixes to the code for
it to compile without warnings when using 'pedantic' or 'ansi' modes with
recent gcc versions under linux and that was presented previously (Jan 2009)
in 2 independent series [1] for each case.

It has been since merged and rebased to the published git HEAD and expanded
for discussion and with the hope it could be easier to merge now that git
is being used for the main repository.

  [PATCH 1/7] confuse: ISO C90 does not support the '%lf' printf format
  [PATCH 2/7] tests: C++ style comments are not allowed in ISO C90
  [PATCH 3/7] tests: ISO C90 forbids mixed declarations and code
  [PATCH 4/7] tests: initializer element is not computable at load time
  [PATCH 5/7] examples: declare source as GNU for strdup definition
  [PATCH 6/7] tests: declare source as GNU for inet_aton definition
  [PATCH 7/7] confuse: declare source as GNU for fileno definition and consolidated code

Carlo

[1] http://lists.gnu.org/archive/html/confuse-devel/2009-01/threads.html


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

[PATCH 1/7] confuse: ISO C90 does not support the ‘%lf’ printf format

Carlo Marcelo Arenas Belon
'%f' is valid for float and double, while '%Lf' is needed for long double
leaving this as a undefined behaviour for C90 and ignored in C99 as shown
by :

  confuse.c:1410: warning: ISO C90 does not support the ‘%lf’ printf format

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

diff --git a/examples/wincfgtest.c b/examples/wincfgtest.c
index 24f6fa5..4a9c1ac 100644
--- a/examples/wincfgtest.c
+++ b/examples/wincfgtest.c
@@ -88,7 +88,7 @@ int main(void)
             if(cfg_parse(cfg, "wincfgtest.conf") == CFG_FILE_ERROR)
                 perror("wincfgtest.conf");
 
-           sprintf(buf, "bool:    %s\nstring:  %s\nnumber:  %ld\nfloat:   %lf\n",
+           sprintf(buf, "bool:    %s\nstring:  %s\nnumber:  %ld\nfloat:   %f\n",
              cfg_getbool(cfg, "bool") ? "true" : "false", cfg_getstr(cfg, "string"),
              cfg_getint(cfg, "number"), cfg_getfloat(cfg, "float"));
            MessageBox(NULL, buf, "libConfuse", MB_OK);
diff --git a/src/confuse.c b/src/confuse.c
index 003d0b9..6e7a0ef 100644
--- a/src/confuse.c
+++ b/src/confuse.c
@@ -1407,7 +1407,7 @@ DLLIMPORT void cfg_opt_nprint_var(cfg_opt_t *opt, unsigned int index, FILE *fp)
             fprintf(fp, "%ld", cfg_opt_getnint(opt, index));
             break;
         case CFGT_FLOAT:
-            fprintf(fp, "%lf", cfg_opt_getnfloat(opt, index));
+            fprintf(fp, "%f", cfg_opt_getnfloat(opt, index));
             break;
         case CFGT_STR:
             str = cfg_opt_getnstr(opt, index);
--
1.7.0.1



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

[PATCH 2/7] tests: C++ style comments are not allowed in ISO C90

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon
remove code which was commented out using "C++" style and that is
not supported by ISO C90, resulting otherwise in an error if ANSI
is required

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

diff --git a/tests/suite_validate.c b/tests/suite_validate.c
index 710016c..a914bfa 100644
--- a/tests/suite_validate.c
+++ b/tests/suite_validate.c
@@ -98,7 +98,6 @@ void validate_setup(void)
     cfg_opt_t multi_opts[] =
     {
         CFG_INT_LIST("speeds", 0, CFGF_NONE),
-        //{"speeds",CFGT_INT,0,0,CFGF_LIST,0,{0,0,cfg_false,0,0},0,0,0,validate_speed,0},
         CFG_SEC("options", action_opts, CFGF_NONE),
         CFG_END()
     };
--
1.7.0.1



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

[PATCH 3/7] tests: ISO C90 forbids mixed declarations and code

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon
move declarations to the begin of each block where they are being used

Signed-off-by: Carlo Marcelo Arenas Belon <[hidden email]>
---
 tests/list_plus_syntax.c   |    9 +++++----
 tests/quote_before_print.c |    6 ++++--
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tests/list_plus_syntax.c b/tests/list_plus_syntax.c
index 76f62f7..53f48e7 100644
--- a/tests/list_plus_syntax.c
+++ b/tests/list_plus_syntax.c
@@ -8,13 +8,14 @@ int main(void)
         CFG_END()
     };
 
+    int rc;
     cfg_t *cfg = cfg_init(opts, CFGF_NONE);
     fail_unless(cfg);
 
-    int rc = cfg_parse_buf(cfg,
-            " stringproperty = {\"this\"}\n"
-            " stringproperty += {\"that\"}\n"
-            " stringproperty += {\"other\"}\n");
+    rc = cfg_parse_buf(cfg,
+        " stringproperty = {\"this\"}\n"
+        " stringproperty += {\"that\"}\n"
+        " stringproperty += {\"other\"}\n");
 
     fail_unless(rc == CFG_SUCCESS);
 
diff --git a/tests/quote_before_print.c b/tests/quote_before_print.c
index 15b02b9..e7e1df7 100644
--- a/tests/quote_before_print.c
+++ b/tests/quote_before_print.c
@@ -16,6 +16,8 @@ cfg_opt_t opts[] =
 int
 main(void)
 {
+ FILE *fp;
+ char *param;
  cfg_t *cfg = cfg_init(opts, CFGF_NONE);
  fail_unless(cfg);
 
@@ -25,7 +27,7 @@ main(void)
 
  /* print the config to a temporary file
  */
- FILE *fp = tmpfile();
+ fp = tmpfile();
  fail_unless(fp);
  cfg_print(cfg, fp);
  cfg_free(cfg);
@@ -38,7 +40,7 @@ main(void)
  fail_unless(cfg_parse_fp(cfg, fp) == CFG_SUCCESS);
  fail_unless(fclose(fp) == 0);
 
- char *param = cfg_getstr(cfg, "parameter");
+ param = cfg_getstr(cfg, "parameter");
  fail_unless(param);
 
  fail_unless(strcmp(param, "text \" with quotes and \\") == 0);
--
1.7.0.1



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

[PATCH 4/7] tests: initializer element is not computable at load time

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon
ISO C90 (until C99) requires that all initializer be constant values
but a pointer to an automatic variable is not kwnown at load time.

make all pointers used as part of CFG_SIMPLE_* and CFG_SEC macros in
the examples and tests, point to a static variable so it can be
considered constant

Signed-off-by: Carlo Marcelo Arenas Belon <[hidden email]>
---
 examples/ftpconf.c          |    2 +-
 examples/reread.c           |    2 +-
 examples/simple.c           |   10 +++++-----
 tests/section_title_dupes.c |    2 +-
 tests/suite_dup.c           |    2 +-
 tests/suite_list.c          |    4 ++--
 tests/suite_single.c        |    6 +++---
 tests/suite_validate.c      |    6 +++---
 8 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/examples/ftpconf.c b/examples/ftpconf.c
index c8497c3..a46db92 100644
--- a/examples/ftpconf.c
+++ b/examples/ftpconf.c
@@ -68,7 +68,7 @@ int conf_validate_bookmark(cfg_t *cfg, cfg_opt_t *opt)
 
 cfg_t *parse_conf(const char *filename)
 {
-    cfg_opt_t bookmark_opts[] = {
+    static cfg_opt_t bookmark_opts[] = {
         CFG_STR("host", 0, CFGF_NODEFAULT),
         CFG_INT("port", 21, CFGF_NONE),
         CFG_STR("login", "anonymous", CFGF_NONE),
diff --git a/examples/reread.c b/examples/reread.c
index fb60776..5fa1042 100644
--- a/examples/reread.c
+++ b/examples/reread.c
@@ -8,7 +8,7 @@ const char *config_filename = "./reread.conf";
 
 void read_config(void)
 {
-    cfg_opt_t arg_opts[] = {
+    static cfg_opt_t arg_opts[] = {
         CFG_STR("value", "default", CFGF_NONE),
         CFG_END()
     };
diff --git a/examples/simple.c b/examples/simple.c
index 9f47ec7..9a6ee51 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -4,10 +4,10 @@
 
 int main(void)
 {
-    cfg_bool_t verbose = cfg_false;
-    char *server = NULL;
-    double delay = 1.356e-32;
-    char *username = NULL;
+    static cfg_bool_t verbose = cfg_false;
+    static char *server = NULL;
+    static double delay = 1.356e-32;
+    static char *username = NULL;
 
     /* Although the macro used to specify an integer option is called
      * CFG_SIMPLE_INT(), it actually expects a long int. On a 64 bit system
@@ -18,7 +18,7 @@ int main(void)
      * cfg_getint(), this is not a problem as the data types are implicitly
      * cast.
      */
-    long int debug = 1;
+    static long int debug = 1;
 
     cfg_opt_t opts[] = {
         CFG_SIMPLE_BOOL("verbose", &verbose),
diff --git a/tests/section_title_dupes.c b/tests/section_title_dupes.c
index ba8b93f..88b0436 100644
--- a/tests/section_title_dupes.c
+++ b/tests/section_title_dupes.c
@@ -3,7 +3,7 @@
 
 int main(void)
 {
-    cfg_opt_t section_opts[] = {
+    static cfg_opt_t section_opts[] = {
         CFG_STR("prop", 0, CFGF_NONE),
         CFG_END()
     };
diff --git a/tests/suite_dup.c b/tests/suite_dup.c
index 8a125fc..189be2a 100644
--- a/tests/suite_dup.c
+++ b/tests/suite_dup.c
@@ -3,7 +3,7 @@
 
 static cfg_t *create_config(void)
 {
-    cfg_opt_t sec_opts[] =
+    static cfg_opt_t sec_opts[] =
     {
         CFG_INT("a", 1, CFGF_NONE),
         CFG_INT("b", 2, CFGF_NONE),
diff --git a/tests/suite_list.c b/tests/suite_list.c
index 862782a..e1e44cf 100644
--- a/tests/suite_list.c
+++ b/tests/suite_list.c
@@ -6,7 +6,7 @@ static int numopts = 0;
 
 static void list_setup(void)
 {
-    cfg_opt_t subsec_opts[] =
+    static cfg_opt_t subsec_opts[] =
     {
         CFG_STR_LIST("subsubstring", 0, CFGF_NONE),
         CFG_INT_LIST("subsubinteger", 0, CFGF_NONE),
@@ -15,7 +15,7 @@ static void list_setup(void)
         CFG_END()
     };
 
-    cfg_opt_t sec_opts[] =
+    static cfg_opt_t sec_opts[] =
     {
         CFG_STR_LIST("substring", "{subdefault1, subdefault2}", CFGF_NONE),
         CFG_INT_LIST("subinteger", "{17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 300}", CFGF_NONE), /* 14 values */
diff --git a/tests/suite_single.c b/tests/suite_single.c
index cb749d6..ded643f 100644
--- a/tests/suite_single.c
+++ b/tests/suite_single.c
@@ -65,7 +65,7 @@ int parse_ether_address(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *res
 
 void single_setup(void)
 {
-    cfg_opt_t subsec_opts[] =
+    static cfg_opt_t subsec_opts[] =
     {
         CFG_STR("subsubstring", "subsubdefault", CFGF_NONE),
         CFG_INT("subsubinteger", -42, CFGF_NONE),
@@ -74,7 +74,7 @@ void single_setup(void)
         CFG_END()
     };
 
-    cfg_opt_t sec_opts[] =
+    static cfg_opt_t sec_opts[] =
     {
         CFG_STR("substring", "subdefault", CFGF_NONE),
         CFG_INT("subinteger", 17, CFGF_NONE),
@@ -84,7 +84,7 @@ void single_setup(void)
         CFG_END()
     };
 
-    cfg_opt_t nodef_opts[] =
+    static cfg_opt_t nodef_opts[] =
     {
         CFG_STR("string", "defvalue", CFGF_NONE),
         CFG_INT("int", -17, CFGF_NODEFAULT),
diff --git a/tests/suite_validate.c b/tests/suite_validate.c
index a914bfa..e29f511 100644
--- a/tests/suite_validate.c
+++ b/tests/suite_validate.c
@@ -13,7 +13,7 @@ static cfg_t *cfg = 0;
 #define ACTION_CRAWL 3
 #define ACTION_JUMP 4
 
-int parse_action(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result)
+static int parse_action(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result)
 {
     if(strcmp(value, "run") == 0)
         *(int *)result = ACTION_RUN;
@@ -87,7 +87,7 @@ void validate_setup(void)
 {
     cfg_opt_t *opt = 0;
 
-    cfg_opt_t action_opts[] =
+    static cfg_opt_t action_opts[] =
     {
         CFG_INT("speed", 0, CFGF_NONE),
         CFG_STR("name", 0, CFGF_NONE),
@@ -95,7 +95,7 @@ void validate_setup(void)
         CFG_END()
     };
 
-    cfg_opt_t multi_opts[] =
+    static cfg_opt_t multi_opts[] =
     {
         CFG_INT_LIST("speeds", 0, CFGF_NONE),
         CFG_SEC("options", action_opts, CFGF_NONE),
--
1.7.0.1



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

[PATCH 5/7] examples: declare source as GNU for strdup definition

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon
otherwise to show the following warning if compiled in -ansi mode :

  simple.c:34: warning: implicit declaration of function ‘strdup’
  simple.c:34: warning: assignment makes pointer from integer without a cast

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 9a6ee51..76266f1 100644
--- a/examples/simple.c
+++ b/examples/simple.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
 #include <string.h>
 #include <stdlib.h>
 #include "confuse.h"
--
1.7.0.1



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

[PATCH 6/7] tests: declare source as GNU for inet_aton definition

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon
otherwise to show the following warning if compiled in -ansi mode :

  suite_single.c:14: warning: implicit declaration of function ‘inet_aton’
  suite_validate.c:57: warning: implicit declaration of function ‘inet_aton’

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

diff --git a/tests/suite_single.c b/tests/suite_single.c
index ded643f..3806a46 100644
--- a/tests/suite_single.c
+++ b/tests/suite_single.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
 #include "check_confuse.h"
 #include <string.h>
 #include <stdlib.h>
diff --git a/tests/suite_validate.c b/tests/suite_validate.c
index e29f511..d68923d 100644
--- a/tests/suite_validate.c
+++ b/tests/suite_validate.c
@@ -1,3 +1,4 @@
+#define _GNU_SOURCE
 #include "check_confuse.h"
 #include <string.h>
 #include <sys/types.h>
--
1.7.0.1



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

[PATCH 7/7] confuse: declare source as GNU for fileno definition and consolidated code

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon
otherwise to show the following warning if compiled in -ansi mode :

  lexer.c:1870: warning: implicit declaration of function ‘fileno’

and the generated lexer.c file uses fileno

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

diff --git a/src/Makefile.am b/src/Makefile.am
index 4e3e830..5fed0eb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,6 +2,7 @@ lib_LTLIBRARIES = libconfuse.la
 
 libconfuse_la_SOURCES = confuse.c lexer.l
 libconfuse_la_LIBADD = $(LTLIBINTL)
+libconfuse_la_CPPFLAGS = -D_GNU_SOURCE
 
 include_HEADERS = confuse.h
 
diff --git a/src/confuse.c b/src/confuse.c
index 6e7a0ef..4e67ba6 100644
--- a/src/confuse.c
+++ b/src/confuse.c
@@ -18,7 +18,6 @@
 # include <config.h>
 #endif
 
-#define _GNU_SOURCE
 #include <sys/types.h>
 #include <string.h>
 #include <stdlib.h>
--
1.7.0.1



_______________________________________________
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/7] trivial compilation fixes for linux.

Martin Hedenfalk-4
In reply to this post by Carlo Marcelo Arenas Belon
They have now been committed, thanks!

        -martin

27 mar 2010 kl. 11.08 skrev Carlo Marcelo Arenas Belon:

> The following patch series consist of a list of trivial fixes to the code for
> it to compile without warnings when using 'pedantic' or 'ansi' modes with
> recent gcc versions under linux and that was presented previously (Jan 2009)
> in 2 independent series [1] for each case.
>
> It has been since merged and rebased to the published git HEAD and expanded
> for discussion and with the hope it could be easier to merge now that git
> is being used for the main repository.
>
>  [PATCH 1/7] confuse: ISO C90 does not support the '%lf' printf format
>  [PATCH 2/7] tests: C++ style comments are not allowed in ISO C90
>  [PATCH 3/7] tests: ISO C90 forbids mixed declarations and code
>  [PATCH 4/7] tests: initializer element is not computable at load time
>  [PATCH 5/7] examples: declare source as GNU for strdup definition
>  [PATCH 6/7] tests: declare source as GNU for inet_aton definition
>  [PATCH 7/7] confuse: declare source as GNU for fileno definition and consolidated code
>
> Carlo
>
> [1] http://lists.gnu.org/archive/html/confuse-devel/2009-01/threads.html
>
>
> _______________________________________________
> 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
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 1/7] confuse: ISO C90 does not support the ???%lf??? printf format

Carlo Marcelo Arenas Belon
In reply to this post by Carlo Marcelo Arenas Belon
On Sat, Mar 27, 2010 at 03:08:28AM -0700, Carlo Marcelo Arenas Belon wrote:
>
> '%f' is valid for float and double, while '%Lf' is needed for long double
> leaving this as a undefined behaviour for C90 and ignored in C99 as shown
> by :
>
>   confuse.c:1410: warning: ISO C90 does not support the ???%lf??? printf format

this will break, at least in mingw32 when using -std=c89 as shown by (not
confuse specific but still a good example of what would happen with
cfg_opt_nprint_*)

  $ cat > float.c
  #include <stdio.h>

  int main(int argc, char *argv[])
  {
    float f = 3.1415926;
    double d = 3.1415926;

    printf("f = %f, d = %lf\n", f, d);
    return 0;
  }^D
  $ i686-pc-mingw32-gcc -std=c89 -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -mms-bitfields float.c -o float.exe
  $ ./float.exe
  f = 3.141593, d = 0.000000

> diff --git a/src/confuse.c b/src/confuse.c
> index 003d0b9..6e7a0ef 100644
> --- a/src/confuse.c
> +++ b/src/confuse.c
> @@ -1407,7 +1407,7 @@ DLLIMPORT void cfg_opt_nprint_var(cfg_opt_t *opt, unsigned int index, FILE *fp)
>              fprintf(fp, "%ld", cfg_opt_getnint(opt, index));
>              break;
>          case CFGT_FLOAT:
> -            fprintf(fp, "%lf", cfg_opt_getnfloat(opt, index));
> +            fprintf(fp, "%f", cfg_opt_getnfloat(opt, index));
>              break;
>          case CFGT_STR:
>              str = cfg_opt_getnstr(opt, index);
> --

this snippet should prevent that, but wasn't committed as part of this patch
in 6d5335a8ac0ea6bdb553931a29bef0e2d21d4e3e

anyone has any objections or is depending on the undefined behaviour that
"%lf" has?

Carlo

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

Re: Re: [PATCH 1/7] confuse: ISO C90 does not support the ???%lf??? printf format

Martin Hedenfalk-4
12 jul 2010 kl. 08.40 skrev Carlo Marcelo Arenas Belon:

> On Sat, Mar 27, 2010 at 03:08:28AM -0700, Carlo Marcelo Arenas Belon wrote:
>>
>> '%f' is valid for float and double, while '%Lf' is needed for long double
>> leaving this as a undefined behaviour for C90 and ignored in C99 as shown
>> by :

We're not using any long doubles, so any %lf formats should just drop the 'l' modifier.


>>  confuse.c:1410: warning: ISO C90 does not support the ???%lf??? printf format
>
> this will break, at least in mingw32 when using -std=c89 as shown by (not
> confuse specific but still a good example of what would happen with
> cfg_opt_nprint_*)
>
>  $ cat > float.c
>  #include <stdio.h>
>
>  int main(int argc, char *argv[])
>  {
>    float f = 3.1415926;
>    double d = 3.1415926;
>
>    printf("f = %f, d = %lf\n", f, d);
>    return 0;
>  }^D
>  $ i686-pc-mingw32-gcc -std=c89 -O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4 -mms-bitfields float.c -o float.exe
>  $ ./float.exe
>  f = 3.141593, d = 0.000000
>
>> diff --git a/src/confuse.c b/src/confuse.c
>> index 003d0b9..6e7a0ef 100644
>> --- a/src/confuse.c
>> +++ b/src/confuse.c
>> @@ -1407,7 +1407,7 @@ DLLIMPORT void cfg_opt_nprint_var(cfg_opt_t *opt, unsigned int index, FILE *fp)
>>             fprintf(fp, "%ld", cfg_opt_getnint(opt, index));
>>             break;
>>         case CFGT_FLOAT:
>> -            fprintf(fp, "%lf", cfg_opt_getnfloat(opt, index));
>> +            fprintf(fp, "%f", cfg_opt_getnfloat(opt, index));
>>             break;
>>         case CFGT_STR:
>>             str = cfg_opt_getnstr(opt, index);
>> --
>
> this snippet should prevent that, but wasn't committed as part of this patch
> in 6d5335a8ac0ea6bdb553931a29bef0e2d21d4e3e
>
> anyone has any objections or is depending on the undefined behaviour that
> "%lf" has?

We don't want any undefined behaviour. Ok.

        -martin


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

Re: Re: [PATCH 1/7] confuse: ISO C90 does not support the ???%lf??? printf format

Carlo Marcelo Arenas Belon
On Mon, Jul 12, 2010 at 09:13:15AM +0200, Martin Hedenfalk wrote:

> 12 jul 2010 kl. 08.40 skrev Carlo Marcelo Arenas Belon:
> >
> >> diff --git a/src/confuse.c b/src/confuse.c
> >> index 003d0b9..6e7a0ef 100644
> >> --- a/src/confuse.c
> >> +++ b/src/confuse.c
> >> @@ -1407,7 +1407,7 @@ DLLIMPORT void cfg_opt_nprint_var(cfg_opt_t *opt, unsigned int index, FILE *fp)
> >>             fprintf(fp, "%ld", cfg_opt_getnint(opt, index));
> >>             break;
> >>         case CFGT_FLOAT:
> >> -            fprintf(fp, "%lf", cfg_opt_getnfloat(opt, index));
> >> +            fprintf(fp, "%f", cfg_opt_getnfloat(opt, index));
> >>             break;
> >>         case CFGT_STR:
> >>             str = cfg_opt_getnstr(opt, index);
> >> --
> >
> > this snippet should prevent that, but wasn't committed as part of this patch
> > in 6d5335a8ac0ea6bdb553931a29bef0e2d21d4e3e
> >
> > anyone has any objections or is depending on the undefined behaviour that
> > "%lf" has?
>
> We don't want any undefined behaviour. Ok.

commited in 042c6ee61019042d0948cd9b5a740e279a32d456

Carlo

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