lzip-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lzip-bug] Version 0.1 of plzip released


From: Antonio Diaz Diaz
Subject: Re: [Lzip-bug] Version 0.1 of plzip released
Date: Tue, 08 Dec 2009 20:34:48 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.7.11) Gecko/20050905

Hello Tino,

Tino Lange wrote:
plzip.cc:601: warning: comparison is always false due to limited range of data 
type

Thanks for reporting this. As John Reiser has already noticed, these are true bugs. As a quick fix, please, try the attached patch.


Best regards,
Antonio.
diff -urdN ../old_src/main.cc ./main.cc
--- ../old_src/main.cc  2009-12-05 22:39:14.000000000 +0100
+++ ./main.cc   2009-12-08 19:48:32.000000000 +0100
@@ -1098,8 +1098,8 @@
   if (UINT_MAX / blf < (unsigned)max_worker) {
     max_worker = UINT_MAX / blf;
   }
-  if ((size_t)-1 / sizeof(pthread_t) < (unsigned)max_worker) {
-    max_worker = (size_t)-1 / sizeof(pthread_t);
+  if (UINT_MAX / sizeof(pthread_t) < (unsigned)max_worker) {
+    max_worker = UINT_MAX / sizeof(pthread_t);
   }
 
   opts.num_worker = 0u;
diff -urdN ../old_src/plzip.cc ./plzip.cc
--- ../old_src/plzip.cc 2009-12-05 22:18:42.000000000 +0100
+++ ./plzip.cc  2009-12-08 20:22:56.000000000 +0100
@@ -580,13 +580,13 @@
     unsigned tmp; \
 \
     tmp = arsz_unsigned; \
-    if ((size_t)-1 < tmp) { \
+    if (UINT_MAX < tmp) { \
       show_error( "size_t overflow in sizeof_" #arr "." ); \
       fatal(); \
     } \
     arg ## _arg . sizeof_ ## arr = tmp; \
 \
-    if ((size_t)-1 - sizeof(struc) \
+    if (UINT_MAX - sizeof(struc) \
         < arg ## _arg . sizeof_ ## arr - (size_t)1) { \
       show_error( "size_t overflow in sizeof_" #struc "." ); \
       fatal(); \
@@ -611,7 +611,7 @@
 #undef SIZES
 
   assert(0u < num_worker);
-  assert((size_t)-1 / sizeof *worker >= num_worker);
+  assert(UINT_MAX / sizeof *worker >= num_worker);
   worker = (pthread_t *)xalloc(num_worker * sizeof *worker);
   for (i = 0u; i < num_worker; ++i) {
     xcreate(&worker[i], work_wrap, &work_arg);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]