On Wed, Jan 02, 2013 at 01:12:15PM -0600, H Hartley Sweeten wrote: > On Wednesday, January 02, 2013 12:03 PM, Ian Abbott wrote: > > On 02/01/2013 18:10, H Hartley Sweeten wrote: > >> Will the munge_count always be larger, or equal, to the buf_read_alloc_count? > >> The original code had the (int) cast so I wasn't sure. If so, then yes the variable > >> should be an unsigned int. > > > > Well the value it is being compared to (nbytes) is an unsigned int, so > > the int value (available) will be converted to unsigned int before the > > comparison anyway. So making 'available' an unsigned int to begin with > > shouldn't break anything that isn't already broke! > > Not so. Simple test: > Uh... Ian is correct. In the new code it doesn't matter if "available" is signed or unsigned because the comparison is always promoted to unsigned. I think you are assuming that 99 is an unsigned int but actually it defaults to int. The test should be something like: int available = -40; unsigned int nbytes = 5; if (nbytes > available) printf("Not promoted\n"); else printf("Negative 'availabled' treated as large unsigned int.\n"); I think the rules are that comparisons are promoted to the type with the most bits for positive integers. That's how I treat them in Smatch. regards, dan carpenter _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/devel