[PATCH] udhcpd: Handle auto_time timeout overflow

Cathey, Jim jcathey at ciena.com
Tue Jan 27 22:22:17 UTC 2015


Oh, and carry bits.  Addition/subtraction are also precision-changing!

-- Jim

From: busybox [mailto:busybox-bounces at busybox.net] On Behalf Of Cathey, Jim
Sent: Tuesday, January 27, 2015 2:19 PM
To: Guillermo Rodriguez Garcia; Tim Hentenaar
Cc: busybox; Rich Felker
Subject: RE: [PATCH] udhcpd: Handle auto_time timeout overflow

Because mathematically, differences are always signed!

                2 - 1 ==  1
                1 - 2 == -1

Doesn't matter what the size, or sign-ability of the LHS
operands are.  C, however, absolutely stinks at mathematical
relations that change the nature of the calculation.  Precision
changing (like integer multiplication and division), sign invention
(like subtraction), etc.

You can work with it, but you must understand what is going on.

-- Jim

From: busybox [mailto:busybox-bounces at busybox.net] On Behalf Of Guillermo Rodriguez Garcia
Sent: Tuesday, January 27, 2015 2:10 PM
To: Tim Hentenaar
Cc: busybox; Rich Felker
Subject: Re: [PATCH] udhcpd: Handle auto_time timeout overflow

El martes, 27 de enero de 2015, Tim Hentenaar <tim at hentenaar.com<mailto:tim at hentenaar.com>> escribió:
Perhaps it wrongly assumes that since the operands for the subtraction
are 32-bit unsigned integers, that the result will be also unsigned.

Uhm, why would that be a wrong assumption ?

Guillermo


--
Guillermo Rodriguez Garcia
guille.rodriguez at gmail.com<mailto:guille.rodriguez at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20150127/332a7034/attachment-0001.html>


More information about the busybox mailing list