Merge lp:~yavor-nikolov/pbzip2/bug-1236086-printf-numeric-type-alignment into lp:pbzip2/1.1

Proposed by Yavor Nikolov
Status: Merged
Merged at revision: 40
Proposed branch: lp:~yavor-nikolov/pbzip2/bug-1236086-printf-numeric-type-alignment
Merge into: lp:pbzip2/1.1
Diff against target: 474 lines (+71/-63)
5 files modified
BZ2StreamScanner.cpp (+15/-13)
BZ2StreamScanner.h (+2/-0)
ChangeLog (+1/-0)
pbzip2.cpp (+50/-50)
pbzip2.h (+3/-0)
To merge this branch: bzr merge lp:~yavor-nikolov/pbzip2/bug-1236086-printf-numeric-type-alignment
Reviewer Review Type Date Requested Status
Yavor Nikolov Approve
Review via email: mp+215574@code.launchpad.net

Description of the change

Fix for #1236086 (printf format vs actual type alignment)

To post a comment you must log in.
42. By Yavor Nikolov

More printf format vs type alignment fixes (1236086)

43. By Yavor Nikolov

More fixes of printf format vs actual type alignment

Revision history for this message
Yavor Nikolov (yavor-nikolov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'BZ2StreamScanner.cpp'
2--- BZ2StreamScanner.cpp 2011-02-12 13:35:21 +0000
3+++ BZ2StreamScanner.cpp 2014-04-13 13:56:00 +0000
4@@ -111,7 +111,7 @@
5 int BZ2StreamScanner::ensureOutBuffCapacity( size_t newSize )
6 {
7 #ifdef PBZIP_DEBUG
8- fprintf( stderr, " start ensureOutBuffCapacity/newSize=%u: [", newSize );
9+ fprintf( stderr, " start ensureOutBuffCapacity/newSize=%"PRIuMAX": [", (uintmax_t) newSize );
10 printCurrentState();
11 fprintf( stderr, "\n" );
12 #endif
13@@ -152,7 +152,7 @@
14 initOutBuff( newBuff, _outBuff.bufSize, _outBuffCapacityHint );
15
16 #ifdef PBZIP_DEBUG
17- fprintf( stderr, " end ensureOutBuffCapacity/newSize=%u: [", newSize );
18+ fprintf( stderr, " end ensureOutBuffCapacity/newSize=%"PRIuMAX": [", (uintmax_t) newSize );
19 printCurrentState();
20 fprintf( stderr, "\n" );
21 #endif
22@@ -486,19 +486,21 @@
23 }
24
25
26+#ifdef PBZIP_DEBUG
27 void BZ2StreamScanner::printCurrentState()
28 {
29- fprintf( stderr, "current=%d, search pos=%d, end pos=%d; s-c=%d"
30+ fprintf( stderr, "current=%ld, search pos=%ld, end pos=%ld; s-c=%ld"
31 "; out buf size=%d; out buf capacity=%d; header found=%d; search status=%d",
32- getInBuffCurrent() - getInBuffBegin(),
33- getInBuffSearchPtr() - getInBuffBegin(),
34- getInBuffEnd() - getInBuffBegin(),
35- getInBuffSearchPtr() - getInBuffCurrent(),
36+ (long)(getInBuffCurrent() - getInBuffBegin()),
37+ (long)(getInBuffSearchPtr() - getInBuffBegin()),
38+ (long)(getInBuffEnd() - getInBuffBegin()),
39+ (long)(getInBuffSearchPtr() - getInBuffCurrent()),
40 (int)_outBuff.bufSize,
41 (int)_outBuffCapacity,
42 (int)isBz2HeaderFound(),
43 (int)getSearchStatus() );
44 }
45+#endif
46
47 /**
48 * Search next bz2 header. Read more data from file if needed.
49@@ -510,8 +512,8 @@
50 BZ2StreamScanner::CharType * BZ2StreamScanner::searchNextHeader()
51 {
52 #ifdef PBZIP_DEBUG
53- fprintf( stderr, " start searchNextHeader %u/%u... : ",
54- getInBuffSearchPtr() - getInBuffBegin(), getInBuffSize() );
55+ fprintf( stderr, " start searchNextHeader %u/%"PRIuMAX"... : ",
56+ (unsigned) (getInBuffSearchPtr() - getInBuffBegin()), (uintmax_t) getInBuffSize() );
57 printCurrentState();
58 fprintf( stderr, "\n" );
59 #endif
60@@ -550,8 +552,8 @@
61 }
62
63 #ifdef PBZIP_DEBUG
64- fprintf( stderr, " end searchNextHeader %u/%u... NOT FOUND: ",
65- getInBuffSearchPtr() - getInBuffBegin(), getInBuffSize() );
66+ fprintf( stderr, " end searchNextHeader %u/%"PRIuMAX"... NOT FOUND: ",
67+ (unsigned) (getInBuffSearchPtr() - getInBuffBegin()), (uintmax_t) getInBuffSize() );
68 printCurrentState();
69 fprintf( stderr, "\n" );
70 #endif
71@@ -678,8 +680,8 @@
72 OFF_T startBlock = blockNum;
73 blockNum += _outBuff.bufSize;
74
75- fprintf( stderr, " end getNextStream/blockRange=[%"PRIu64", %"PRIu64"), stream no=%d; seq=%d: [",
76- startBlock, blockNum, _outBuff.blockNumber, _outBuff.sequenceNumber );
77+ fprintf( stderr, " end getNextStream/blockRange=[%"PRIuMAX", %"PRIuMAX"), stream no=%d; seq=%d: [",
78+ (uintmax_t) startBlock, (uintmax_t) blockNum, _outBuff.blockNumber, _outBuff.sequenceNumber );
79 printCurrentState();
80 fprintf( stderr, "\n" );
81 #endif
82
83=== modified file 'BZ2StreamScanner.h'
84--- BZ2StreamScanner.h 2011-02-12 13:35:21 +0000
85+++ BZ2StreamScanner.h 2014-04-13 13:56:00 +0000
86@@ -66,7 +66,9 @@
87 */
88 virtual void dispose();
89
90+ #ifdef PBZIP_DEBUG
91 void printCurrentState();
92+ #endif
93
94 private:
95 /* disable copy c-tor */
96
97=== modified file 'ChangeLog'
98--- ChangeLog 2014-04-11 19:43:25 +0000
99+++ ChangeLog 2014-04-13 13:56:00 +0000
100@@ -3,6 +3,7 @@
101 - Makefile refinements
102 - close redirected stdout on finish for better AFS/NFS support (bug #1300876)
103 Thanks to Richard Brittain
104+- Fix printf format vs actual type misalignments (#1236086)
105 Changes in 1.1.8 (Jun 10, 2012)
106 - Fix of metadata unpreserved on empty files compress (bug #1011021)
107 Changes in 1.1.7 (Dec 11, 2011)
108
109=== modified file 'pbzip2.cpp'
110--- pbzip2.cpp 2014-04-11 19:36:32 +0000
111+++ pbzip2.cpp 2014-04-13 13:56:00 +0000
112@@ -513,8 +513,8 @@
113 waitTimer.tv_sec += seconds;
114 #endif
115 #ifdef PBZIP_DEBUG
116- fprintf(stderr, "%s: waitTimer.tv_sec: %d waitTimer.tv_nsec: %lld\n", caller, waitTimer.tv_sec,
117- (long long)waitTimer.tv_nsec);
118+ fprintf(stderr, "%s: waitTimer.tv_sec: %"PRIiMAX" waitTimer.tv_nsec: %"PRIiMAX"\n", caller,
119+ (intmax_t)waitTimer.tv_sec, (intmax_t)waitTimer.tv_nsec);
120 #endif
121 int pret = pthread_cond_timedwait(cond, mutex, &waitTimer);
122 // we are not using a compatible pthreads library so abort
123@@ -814,8 +814,8 @@
124
125 safe_mutex_lock(OutMutex);
126 #ifdef PBZIP_DEBUG
127- unsigned long long thid = (unsigned long long) pthread_self();
128- fprintf(stderr, "(%"PRIu64") syncSetLastGoodBlock: %d -> %d; MinErrorBlock: %d -> %d\n",
129+ uintmax_t thid = (uintmax_t) pthread_self();
130+ fprintf(stderr, "(%"PRIuMAX") syncSetLastGoodBlock: %d -> %d; MinErrorBlock: %d -> %d\n",
131 thid, LastGoodBlock, newValue, MinErrorBlock, errBlock);
132 #endif
133
134@@ -920,9 +920,9 @@
135 int waitForPreviousBlock(int blockNumToWait, int errBlockNumber)
136 {
137 #ifdef PBZIP_DEBUG
138- unsigned long long thid = (unsigned long long) pthread_self();
139+ uintmax_t thid = (uintmax_t) pthread_self();
140 safe_mutex_lock(OutMutex);
141- fprintf( stderr, "(%"PRIu64") waitForPreviousBlock enter: LastGoodBlock=%d"
142+ fprintf( stderr, "(%"PRIuMAX") waitForPreviousBlock enter: LastGoodBlock=%d"
143 "; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d; errBlockNumber=%d\n",
144 thid,
145 LastGoodBlock, blockNumToWait, NextBlockToWrite,
146@@ -935,7 +935,7 @@
147 if (syncGetTerminateFlag() != 0)
148 {
149 #ifdef PBZIP_DEBUG
150- fprintf(stderr, "(%"PRIu64") waitForPreviousBlock terminated [%d]: blockNumToWait=%d\n",
151+ fprintf(stderr, "(%"PRIuMAX") waitForPreviousBlock terminated [%d]: blockNumToWait=%d\n",
152 thid, -1, blockNumToWait );
153 #endif
154 return -1;
155@@ -944,7 +944,7 @@
156 safe_mutex_lock(OutMutex);
157
158 #ifdef PBZIP_DEBUG
159- fprintf( stderr, "(%"PRIu64") waitForPreviousBlock before check: LastGoodBlock=%d; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d\n",
160+ fprintf( stderr, "(%"PRIuMAX") waitForPreviousBlock before check: LastGoodBlock=%d; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d\n",
161 thid, LastGoodBlock, blockNumToWait, NextBlockToWrite, MinErrorBlock );
162 #endif
163
164@@ -952,7 +952,7 @@
165 if ( (MinErrorBlock != -1) && (MinErrorBlock < errBlockNumber) )
166 {
167 #ifdef PBZIP_DEBUG
168- fprintf( stderr, "(%"PRIu64") waitForPreviousBlock exit [%d]: LastGoodBlock=%d; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d\n",
169+ fprintf( stderr, "(%"PRIuMAX") waitForPreviousBlock exit [%d]: LastGoodBlock=%d; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d\n",
170 thid, 2, LastGoodBlock, blockNumToWait, NextBlockToWrite, MinErrorBlock );
171 #endif
172 safe_mutex_unlock(OutMutex);
173@@ -962,7 +962,7 @@
174 if (errBlockNumber <= NextBlockToWrite)
175 {
176 #ifdef PBZIP_DEBUG
177- fprintf( stderr, "(%"PRIu64") waitForPreviousBlock exit [%d]: LastGoodBlock=%d; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d\n",
178+ fprintf( stderr, "(%"PRIuMAX") waitForPreviousBlock exit [%d]: LastGoodBlock=%d; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d\n",
179 thid, 0, LastGoodBlock, blockNumToWait, NextBlockToWrite, MinErrorBlock );
180 #endif
181 safe_mutex_unlock(OutMutex);
182@@ -970,7 +970,7 @@
183 }
184
185 #ifdef PBZIP_DEBUG
186- fprintf( stderr, "(%"PRIu64") waitForPreviousBlock to sleep: LastGoodBlock=%d; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d\n",
187+ fprintf( stderr, "(%"PRIuMAX") waitForPreviousBlock to sleep: LastGoodBlock=%d; blockNumToWait=%d; NextBlockToWrite=%d; MinErrorBlock=%d\n",
188 thid, LastGoodBlock, blockNumToWait, NextBlockToWrite, MinErrorBlock );
189 #endif
190
191@@ -1018,8 +1018,8 @@
192 int exitCode)
193 {
194 #ifdef PBZIP_DEBUG
195- unsigned long long thid = (unsigned long long) pthread_self();
196- fprintf(stderr, "(%"PRIu64") enter issueDecompressError: msg=%s; ret=%d; block=%d; seq=%d; isLastInSeq=%d; avail_in=%d\n",
197+ uintmax_t thid = (uintmax_t) pthread_self();
198+ fprintf(stderr, "(%"PRIuMAX") enter issueDecompressError: msg=%s; ret=%d; block=%d; seq=%d; isLastInSeq=%d; avail_in=%d\n",
199 thid,
200 errmsg, bzret, fileData->blockNumber,
201 outSequenceNumber, (int)fileData->isLastInSequence, strm.avail_in);
202@@ -1054,8 +1054,8 @@
203 int lastGoodBlock = getLastGoodBlockBeforeErr(fileData->blockNumber, outSequenceNumber);
204
205 #ifdef PBZIP_DEBUG
206- unsigned long long thid = (unsigned long long) pthread_self();
207- fprintf(stderr, "(%"PRIu64") enter decompressErrCheckSingle: msg=%s; ret=%d; block=%d; seq=%d; isLastInSeq=%d; avail_in=%d; lastGoodBlock=%d\n",
208+ uintmax_t thid = (uintmax_t) pthread_self();
209+ fprintf(stderr, "(%"PRIuMAX") enter decompressErrCheckSingle: msg=%s; ret=%d; block=%d; seq=%d; isLastInSeq=%d; avail_in=%d; lastGoodBlock=%d\n",
210 thid,
211 errmsg, bzret, fileData->blockNumber,
212 outSequenceNumber, (int)fileData->isLastInSequence, strm.avail_in, lastGoodBlock);
213@@ -1480,8 +1480,8 @@
214 // give warning to user if block is larger than 250 million bytes
215 if (fileData->bufSize > 250000000)
216 {
217- fprintf(stderr, "pbzip2: *WARNING: Compressed block size is large [%"PRIu64" bytes].\n",
218- (unsigned long long) fileData->bufSize);
219+ fprintf(stderr, "pbzip2: *WARNING: Compressed block size is large [%"PRIuMAX" bytes].\n",
220+ (uintmax_t) fileData->bufSize);
221 fprintf(stderr, " If program aborts, use regular BZIP2 to decompress.\n");
222 }
223 }
224@@ -1504,8 +1504,8 @@
225 }
226 }
227 #ifdef PBZIP_DEBUG
228- fprintf(stderr, "producer: Buffer: %x Size: %"PRIu64" Block: %d\n", fileData->buf,
229- (unsigned long long)fileData->bufSize, NumBlocks);
230+ fprintf(stderr, "producer: Buffer: %p Size: %"PRIuMAX" Block: %d\n", fileData->buf,
231+ (uintmax_t)fileData->bufSize, NumBlocks);
232 #endif
233
234 fifo->add(fileData);
235@@ -1561,7 +1561,7 @@
236 bool isInterrupted = false;
237
238 #ifdef PBZIP_DEBUG
239- unsigned long long thid = (unsigned long long) pthread_self();
240+ uintmax_t thid = (uintmax_t) pthread_self();
241 #endif
242
243 if (syncGetTerminateFlag() != 0)
244@@ -1569,7 +1569,7 @@
245 isInterrupted = true;
246
247 #ifdef PBZIP_DEBUG
248- fprintf (stderr, "(%"PRIu64") consumer_decompress: interrupt1 - TerminateFlag set.\n", thid);
249+ fprintf (stderr, "(%"PRIuMAX") consumer_decompress: interrupt1 - TerminateFlag set.\n", thid);
250 #endif
251 }
252 int minErrBlock = syncGetMinErrorBlock();
253@@ -1581,7 +1581,7 @@
254 isInterrupted = true;
255
256 #ifdef PBZIP_DEBUG
257- fprintf (stderr, "(%"PRIu64") consumer_decompress: terminating1 - LastGoodBlock set [%d].\n", thid, syncGetLastGoodBlock());
258+ fprintf (stderr, "(%"PRIuMAX") consumer_decompress: terminating1 - LastGoodBlock set [%d].\n", thid, syncGetLastGoodBlock());
259 #endif
260 }
261
262@@ -1669,8 +1669,8 @@
263 }
264
265 #ifdef PBZIP_DEBUG
266- fprintf(stderr, "consumer: FileData: %x\n", fileData);
267- fprintf(stderr, "consumer: Buffer: %x Size: %u Block: %d\n",
268+ fprintf(stderr, "consumer: FileData: %p\n", fileData);
269+ fprintf(stderr, "consumer: Buffer: %p Size: %u Block: %d\n",
270 fileData->buf, (unsigned)fileData->bufSize, fileData->blockNumber);
271 #endif
272
273@@ -1838,7 +1838,7 @@
274 disposeMemory(fileData->buf);
275
276 #ifdef PBZIP_DEBUG
277- fprintf(stderr, " OutputBuffer[%d].buf = %x\n", fileData->blockNumber, DecompressedData);
278+ fprintf(stderr, " OutputBuffer[%d].buf = %p\n", fileData->blockNumber, DecompressedData);
279 fprintf(stderr, " OutputBuffer[%d].bufSize = %u\n", fileData->blockNumber, outSize);
280 fflush(stderr);
281 #endif
282@@ -1925,13 +1925,13 @@
283 safe_mutex_lock(OutMutex);
284 #ifdef PBZIP_DEBUG
285 outBuff * lastnext = (prevBlockInSequence != NULL) ? prevBlockInSequence->next : NULL;
286- fprintf(stderr, "fileWriter: Block: %d Size: %u Next File Block: %d"
287- ", outBufferPos: %u, NumBlocks: %d, producerDone: %d, lastseq=%d"
288- ", prev=%llx, next=%llx\n",
289- currBlock, NumBufferedBlocksMax, NextBlockToWrite,
290- outBufferPos, NumBlocks, syncGetProducerDone(), lastseq,
291- (unsigned long long)prevBlockInSequence,
292- (unsigned long long)lastnext);
293+ fprintf(stderr, "fileWriter: Block: %d Size: %"PRIuMAX" Next File Block: %d"
294+ ", outBufferPos: %"PRIuMAX", NumBlocks: %d, producerDone: %d, lastseq=%d"
295+ ", prev=%p, next=%p\n",
296+ currBlock, (uintmax_t)NumBufferedBlocksMax, NextBlockToWrite,
297+ (uintmax_t)outBufferPos, NumBlocks, syncGetProducerDone(), lastseq,
298+ prevBlockInSequence,
299+ lastnext);
300 #endif
301
302 if ( (LastGoodBlock != -1) && (NextBlockToWrite > LastGoodBlock) )
303@@ -1970,7 +1970,7 @@
304 }
305
306 #ifdef PBZIP_DEBUG
307- fprintf(stderr, "fileWriter: Buffer: %x Size: %u Block: %d, Seq: %d, isLast: %d\n",
308+ fprintf(stderr, "fileWriter: Buffer: %p Size: %u Block: %d, Seq: %d, isLast: %d\n",
309 OutputBuffer[outBufferPos].buf, OutputBuffer[outBufferPos].bufSize, currBlock,
310 outBlock->sequenceNumber, (int)outBlock->isLastInSequence);
311 #endif
312@@ -2052,7 +2052,7 @@
313 }
314
315 #ifdef PBZIP_DEBUG
316- fprintf(stderr, "Completed: %d%% NextBlockToWrite: %d/%u \r", percentComplete, NextBlockToWrite, NumBufferedBlocksMax);
317+ fprintf(stderr, "Completed: %d%% NextBlockToWrite: %d/%"PRIuMAX" \r", percentComplete, NextBlockToWrite, (uintmax_t)NumBufferedBlocksMax);
318 fflush(stderr);
319 #else
320 if (percentComplete != percentCompleteOld)
321@@ -2090,7 +2090,7 @@
322
323 if (QuietMode != 1)
324 {
325- fprintf(stderr, " Output Size: %"PRIu64" bytes\n", (unsigned long long)CompressedSize);
326+ fprintf(stderr, " Output Size: %"PRIuMAX" bytes\n", (uintmax_t)CompressedSize);
327 }
328
329 #ifdef PBZIP_DEBUG
330@@ -2116,7 +2116,7 @@
331 percentComplete = 100;
332
333 #ifdef PBZIP_DEBUG
334- fprintf(stderr, "Completed: %d%% NextBlockToWrite: %d/%u \r", percentComplete, NextBlockToWrite, NumBufferedBlocksMax);
335+ fprintf(stderr, "Completed: %d%% NextBlockToWrite: %d/%"PRIuMAX" \r", percentComplete, NextBlockToWrite, (uintmax_t)NumBufferedBlocksMax);
336 fflush(stderr);
337 #else
338
339@@ -2190,7 +2190,7 @@
340 inSize = bytesLeft;
341
342 #ifdef PBZIP_DEBUG
343- fprintf(stderr, " -> Bytes To Read: %"PRIu64" bytes...\n", inSize);
344+ fprintf(stderr, " -> Bytes To Read: %"PRIuMAX" bytes...\n", (uintmax_t)inSize);
345 #endif
346
347 // allocate memory to read in file
348@@ -2267,7 +2267,7 @@
349 }
350
351 #ifdef PBZIP_DEBUG
352- fprintf(stderr, "\n Original Block Size: %u\n", inSize);
353+ fprintf(stderr, "\n Original Block Size: %"PRIuMAX"\n", (uintmax_t)inSize);
354 fprintf(stderr, " Compressed Block Size: %u\n", outSize);
355 #endif
356
357@@ -2333,7 +2333,7 @@
358 close(hOutfile);
359 if (QuietMode != 1)
360 {
361- fprintf(stderr, " Output Size: %"PRIu64" bytes\n", (unsigned long long)CompressedSize);
362+ fprintf(stderr, " Output Size: %"PRIuMAX" bytes\n", (uintmax_t)CompressedSize);
363 }
364
365 syncSetProducerDone(1); // Not really needed for direct version
366@@ -2689,7 +2689,7 @@
367 inSize = blockSize;
368
369 #ifdef PBZIP_DEBUG
370- fprintf(stderr, " -> Bytes To Read: %"PRIu64" bytes...\n", inSize);
371+ fprintf(stderr, " -> Bytes To Read: %"PRIuMAX" bytes...\n", (uintmax_t)inSize);
372 #endif
373
374 // allocate memory to read in file
375@@ -2750,7 +2750,7 @@
376 }
377 }
378 #ifdef PBZIP_DEBUG
379- fprintf(stderr, "producer: Buffer: %x Size: %"PRIu64" Block: %d\n", FileData, inSize, NumBlocks);
380+ fprintf(stderr, "producer: Buffer: %p Size: %"PRIuMAX" Block: %d\n", FileData, (uintmax_t)inSize, NumBlocks);
381 #endif
382
383 outBuff * queueElement = new(std::nothrow) outBuff(FileData, inSize, NumBlocks, 0);
384@@ -2843,7 +2843,7 @@
385 }
386
387 #ifdef PBZIP_DEBUG
388- fprintf(stderr, "consumer: Buffer: %x Size: %u Block: %d\n",
389+ fprintf(stderr, "consumer: Buffer: %p Size: %u Block: %d\n",
390 fileData->buf, (unsigned)fileData->bufSize, fileData->blockNumber);
391 #endif
392
393@@ -3068,7 +3068,7 @@
394 // unlikely to get here since more likely exception will be thrown
395 if (OutputBuffer.size() != size)
396 {
397- fprintf(stderr, "pbzip2: *ERROR: Could not initialize (OutputBuffer); size=%u! Aborting...\n", size);
398+ fprintf(stderr, "pbzip2: *ERROR: Could not initialize (OutputBuffer); size=%"PRIuMAX"! Aborting...\n", (uintmax_t)size);
399 safe_mutex_unlock(OutMutex);
400 exit(1);
401 }
402@@ -3762,7 +3762,7 @@
403 continue;
404 }
405 #ifdef PBZIP_DEBUG
406- fprintf(stderr, "argv[%u]: %s Len: %d\n", i, argv[i], strlen(argv[i]));
407+ fprintf(stderr, "argv[%u]: %s Len: %d\n", (unsigned)i, argv[i], (int)strlen(argv[i]));
408 #endif
409 // get command line options with single "-"
410 // check for multiple switches grouped together
411@@ -3997,11 +3997,11 @@
412
413 // do sanity check to make sure integers are the size we expect
414 #ifdef PBZIP_DEBUG
415- fprintf(stderr, "off_t size: %u uint size: %u\n", sizeof(OFF_T), sizeof(unsigned int));
416+ fprintf(stderr, "off_t size: %u uint size: %u\n", (unsigned)sizeof(OFF_T), (unsigned)sizeof(unsigned int));
417 #endif
418 if (sizeof(OFF_T) <= 4)
419 {
420- fprintf(stderr, "\npbzip2: *WARNING: off_t variable size only %u bits!\n", sizeof(OFF_T)*CHAR_BIT);
421+ fprintf(stderr, "\npbzip2: *WARNING: off_t variable size only %u bits!\n", (unsigned)(sizeof(OFF_T)*CHAR_BIT));
422 if (decompress == 1)
423 fprintf(stderr, " You will only able to uncompress files smaller than 2GB in size.\n\n");
424 else
425@@ -4370,7 +4370,7 @@
426 if (decompress == 1)
427 fprintf(stderr, " BWT Block Size: %c00k\n", BWTblockSizeChar);
428 if (strcmp(InFilename, "-") != 0)
429- fprintf(stderr, " Input Size: %"PRIu64" bytes\n", (unsigned long long)InFileSize);
430+ fprintf(stderr, " Input Size: %"PRIuMAX" bytes\n", (uintmax_t)InFileSize);
431 }
432
433 if (decompress == 1)
434@@ -4445,7 +4445,7 @@
435 }
436 if (QuietMode != 1)
437 {
438- fprintf(stderr, " Output Size: %"PRIu64" bytes\n", (unsigned long long)sizeof(Bz2HeaderZero));
439+ fprintf(stderr, " Output Size: %u bytes\n", (unsigned)sizeof(Bz2HeaderZero));
440 fprintf(stderr, "-------------------------------------------\n");
441 }
442 // remove input file unless requested not to by user or error occurred
443@@ -4482,7 +4482,7 @@
444 NumBufferedBlocksMax = NumBufferedBlocksMax - (numCPU * 2);
445 #ifdef PBZIP_DEBUG
446 fprintf(stderr, "pbzip2: maxMemory: %d blockSize: %d\n", maxMemory, blockSize);
447- fprintf(stderr, "pbzip2: NumBufferedBlocksMax: %u\n", NumBufferedBlocksMax);
448+ fprintf(stderr, "pbzip2: NumBufferedBlocksMax: %"PRIuMAX"\n", (uintmax_t)NumBufferedBlocksMax);
449 #endif
450 // check to see if our max buffered blocks is less than numCPU, if yes increase maxMemory
451 // to support numCPU requested unless -m switch given by user
452@@ -4492,7 +4492,7 @@
453 {
454 NumBufferedBlocksMax = numCPU;
455 if (QuietMode != 1)
456- fprintf(stderr, "*Warning* Max memory limit increased to %d MB to support %d CPUs\n", ((NumBufferedBlocksMax + (numCPU * 2)) * blockSize)/1000000, numCPU);
457+ fprintf(stderr, "*Warning* Max memory limit increased to %"PRIuMAX" MB to support %d CPUs\n", (uintmax_t)((NumBufferedBlocksMax + (numCPU * 2)) * blockSize)/1000000, numCPU);
458 }
459 else
460 {
461
462=== modified file 'pbzip2.h'
463--- pbzip2.h 2011-07-11 21:22:50 +0000
464+++ pbzip2.h 2014-04-13 13:56:00 +0000
465@@ -53,6 +53,9 @@
466
467 #include <stdio.h>
468 #include <pthread.h>
469+
470+#define __STDC_FORMAT_MACROS
471+#include <inttypes.h>
472 }
473
474 // uncomment for debug output

Subscribers

People subscribed via source and target branches