[PATCH] Don't use labs() on an unsigned values
Jeremy Allison
jra at samba.org
Wed Dec 23 06:45:01 UTC 2015
On Tue, Dec 22, 2015 at 04:55:59PM +1300, Douglas Bagnall wrote:
> I found this lying around with the subnet patches. Courtesy of clang, IIRC.
>
If you fix the spacing to look like:
+ /* Samba's NTTIME is unsigned, abs() won't work! */
+ if (nt0 > nt1) {
+ ret = nt0 - nt1;
+ } else {
+ ret = nt1 - nt0;
+ }
so it matches the way we use braces and spacing, then:
Reviewed-by: Jeremy Allison <jra at samba.org>
Can I get a second Team reviewer ?
> From fede07cc89f5e70dec0c03875d954f95556d2b1d Mon Sep 17 00:00:00 2001
> From: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
> Date: Tue, 22 Dec 2015 14:18:19 +1300
> Subject: [PATCH] torture/gentest time_skew(): don't use labs() on unsigned
> NTTIME
>
> Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
> ---
> source4/torture/gentest.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c
> index 41b4aef..601c3b2 100644
> --- a/source4/torture/gentest.c
> +++ b/source4/torture/gentest.c
> @@ -295,7 +295,13 @@ static unsigned int time_skew(void)
> nt0 = servers[0].smb_tree[0]->session->transport->negotiate.server_time;
> nt1 = servers[1].smb_tree[0]->session->transport->negotiate.server_time;
> }
> - ret = labs(nt0 - nt1);
> + /* Samba's NTTIME is unsigned, abs() won't work! */
> + if (nt0 > nt1){
> + ret = nt0 - nt1;
> + }
> + else {
> + ret = nt1 - nt0;
> + }
> return ret + 300;
> }
>
> --
> 2.1.4
>
More information about the samba-technical
mailing list