OS X 10.8.4 "make" command generates warnings

Bug #1236086 reported by haikuty on 2013-10-06
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pbzip2
Low
Yavor Nikolov

Bug Description

Doing a make in OS X 10.8.4 generates some warnings that look potentially problematic since they are variable size issues.. Particular in BZ2StreamScanner.cpp

output:

$ make
g++ -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_POSIX_PTHREAD_SEMANTICS -DUSE_STACKSIZE_CUSTOMIZATION -pthread pbzip2.cpp BZ2StreamScanner.cpp ErrorContext.cpp -o pbzip2 -lbz2 -lpthread
pbzip2.cpp:2999:99: warning: format specifies type 'unsigned int' but the argument has type 'size_t'
      (aka 'unsigned long') [-Wformat]
                fprintf(stderr, "pbzip2: *ERROR: Could not initialize (OutputBuffer); size=%u! Aborting...\n", size);
                                                                                           ~~ ^~~~
                                                                                           %lu
pbzip2.cpp:3943:79: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
  ...fprintf(stderr, "\npbzip2: *WARNING: off_t variable size only %u bits!\n", sizeof(OFF_T)*CHAR_BIT);
                                                                   ~~ ^~~~~~~~~~~~~~~~~~~~~~
                                                                   %lu
pbzip2.cpp:4428:92: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
  ...limit increased to %d MB to support %d CPUs\n", ((NumBufferedBlocksMax + (numCPU * 2)) * blockSize)/1000000, num...
                        ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                        %lu
3 warnings generated.
BZ2StreamScanner.cpp:493:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                        getInBuffCurrent() - getInBuffBegin(),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BZ2StreamScanner.cpp:494:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                        getInBuffSearchPtr() - getInBuffBegin(),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BZ2StreamScanner.cpp:495:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                        getInBuffEnd() - getInBuffBegin(),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BZ2StreamScanner.cpp:496:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                        getInBuffSearchPtr() - getInBuffCurrent(),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.

Configuration information:

For: pbzip2-1.1.6
iMac Core i5, OS X 10.8.4

$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.76) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix

Related branches

Yavor Nikolov (yavor-nikolov) wrote :

Thanks for reporting this. Is the same reproducible with version 1.1.8?
(These printf statements shouldn't be something critical. Yet - good if we can make it a bit cleaner).

This behaviour depends on compiler (32 or 64-bit and other details). Needs some thinking to figure out what would be the best way to adress the issue.
A discussion on similar topic is here: http://stackoverflow.com/questions/2524611/how-to-print-size-t-variable-portably

haikuty (tyler-q) wrote :
Download full text (4.2 KiB)

Ah, sorry. I didn't see that there was a newer version because I found pbzip2 here: http://compression.ca/pbzip2/ and the latest version listed there is the 1.1.6 I used.

Yes, that stack overflow answer does seem like the right answer.

Version 1.1.8 seems to have the same issues:

$ make
g++ -O2 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_POSIX_PTHREAD_SEMANTICS -DUSE_STACKSIZE_CUSTOMIZATION -pthread pbzip2.cpp BZ2StreamScanner.cpp ErrorContext.cpp -o pbzip2 -lbz2 -lpthread
pbzip2.cpp:3071:99: warning: format specifies type 'unsigned int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
                fprintf(stderr, "pbzip2: *ERROR: Could not initialize (OutputBuffer); size=%u! Aborting...\n", size);
                                                                                           ~~ ^~~~
                                                                                           %lu
pbzip2.cpp:4003:79: warning: format specifies type 'unsigned int' but the argument has type 'unsigned long' [-Wformat]
                        fprintf(stderr, "\npbzip2: *WARNING: off_t variable size only %u bits!\n", sizeof(OFF_T)*CHAR_BIT);
                                                                                      ~~ ^~~~~~~~~~~~~~~~~~~~~~
                                                                                      %lu
pbzip2.cpp:4494:92: warning: format specifies type 'int' but the argument has type 'unsigned long' [-Wformat]
  ...fprintf(stderr, "*Warning* Max memory limit increased to %d MB to support %d CPUs\n", ((NumBufferedBlocksMax + (numCPU * 2)) * blockSize)/1000000, numCPU);
                                                              ~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                              %lu
3 warnings generated.
BZ2StreamScanner.cpp:493:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                        getInBuffCurrent() - getInBuffBegin(),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BZ2StreamScanner.cpp:494:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                        getInBuffSearchPtr() - getInBuffBegin(),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BZ2StreamScanner.cpp:495:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                        getInBuffEnd() - getInBuffBegin(),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BZ2StreamScanner.cpp:496:4: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                        getInBuffSearchPtr() - getInBuffCurrent(),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.

I changed it to use the type safe version as per that SO post and this took care of the compiler warnings. Here's the diff output for the changes to 1.1.8 to remove the warnings (sorry don't have bzr and doesn't look like something worth installing/learning at this point since it appears to be dying slowly):

-----...

Read more...

On Mon, Oct 7, 2013 at 1:51 AM, haikuty <email address hidden> wrote:
> Ah, sorry. I didn't see that there was a newer version because I found
> pbzip2 here: http://compression.ca/pbzip2/ and the latest version
> listed there is the 1.1.6 I used.

Wow, I didn't realize the website was two versions behind, I will have
to fix that ASAP. Sorry about that.

Jeff.

Changed in pbzip2:
assignee: nobody → Yavor Nikolov (yavor-nikolov)
milestone: none → 1.1.9
status: New → In Progress
Changed in pbzip2:
importance: Undecided → Low
status: In Progress → Fix Committed
Changed in pbzip2:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers