Fixed the "too many arguments for format".

  Also just added a better cdGetFileName.

  Sorry, but I'm not going to replace sprintf anytime soon. Nor add a const
declaration to those strings. This is very low priority now.

Best,
Scuri


2018-03-16 6:40 GMT-03:00 sur-behoffski <sur_behoff...@grouse.com.au>:

> G'day,
>
> Previously, the compiler complained long and loud about dynamic strings
> being used as format specifiers in the PPTX driver (cd/src/drv/pptx.c).
>
> When I first reported this, I noted that the warnings could be stopped
> by adding a const, e.g. changing:
>
>         const char *pPPTXItem = "This is not a pipe!";
>
> to:
>
>         const char * const pPPTXItem = "This is not a pipe!";
>
> The warnings have been addressed, but via a different approach:  The
> fprintf calls for strings without any format specifiers have been
> changed from:
>
>         fprintf(pFile, pPPTXItem);
>
> to:
>
>         fprintf(pFile, "%s", pPPTXItem);
>
> Where there was one or more parameters to a (f)printf call, there were
> no warnings that were detected/reported by my build + summary tools.
>
> However, gcc 6.4.x (under Gentoo) does generate more warnings, in a
> variety of areas (the summary totals over 1300 lines at present!)
> This post will only look at the "extra const" case above.
>
> The benefit of static, rather than dynamic, format strings is that
> modern compilers can do static checking on the sanity/coherence of
> the format directives versus the supplied arguments.  In the case of
> pptx.c, three minor cases of extra arguments were identified with
> gcc 5.4.x on the Mint system, once "const" was added:
>
>
>         too many arguments for format [-Wformat-extra-args]:
>             drv/pptx.c:993:[Function:pptxHatchLine]:
>               };
>             drv/pptx.c:1059:[Function:pptxEndLine]:
>               };
>             drv/pptx.c:1074:[Function:pptxEndLine]:
>               };
>
>
> The attached file contains the patch that adds the "const" qualifier
> to the problem cases.  (Originally I added "const" almost everywhere,
> but have stripped it down here, for the sake of brevity.)
>
> cheers,
>
> s-b etc
> programmer, Grouse Software
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Iup-users mailing list
> Iup-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to