Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 115 - Fix format specifier for printf in png2dbl #34

Open
netsweng opened this issue Aug 18, 2013 · 2 comments
Open

Bug 115 - Fix format specifier for printf in png2dbl #34

netsweng opened this issue Aug 18, 2013 · 2 comments

Comments

@netsweng
Copy link
Member

Brad Smith 2011-10-26 19:19:37 EDT

Created an attachment (id=41) [details]
png2bl printf patch

Fix format specifier for a printf in png2dbl. The type used within struct
pngdata for width and height are 32-bit types not 64-bit.

@netsweng
Copy link
Member Author

strk@keybit.net 2011-10-27 03:01:11 EDT

Here .width and .height are png_uint_32, which is:

/usr/include/pngconf.h:typedef unsigned long png_uint_32;

This test, run with -Wall on both 32bit and 64bit machines
shows there should be no warning in those lines:

---8<----------------------

#include <stdio.h>

int
main()
{
long int a = 1;
int b = 2;
unsigned long int c = 3;

    printf("%d\n", a); // warning here
    printf("%ld\n", a);

    printf("%d\n", b);
    printf("%ld\n", b); // warning here

    printf("%d\n", c); // warning here
    printf("%ld\n", c);

}

---8<-----------------------

Do you get the same warnings as reported with the above test ?
Does your png header define .width and .height in some other way ?

@netsweng
Copy link
Member Author

--- util/png2dbl.c.orig Tue Jul 5 23:38:54 2011
+++ util/png2dbl.c Tue Jul 5 23:40:30 2011
@@ -108,7 +108,7 @@ struct pngdata readPNG(FILE *fp)

if(verbose)
{

  • printf("size %ld/%ld color %d/%d/%ld\n",
  • printf("size %d/%d color %d/%d/%d\n",
    png.width, png.height, png.bit_depth, png.color_type,
    png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS));
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant