[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-arch
Subject:    Re: Buggy sbspace() on 64bit builds?
From:       Bruce Evans <brde () optusnet ! com ! au>
Date:       2015-02-07 7:09:47
Message-ID: 20150207180005.F1334 () besplex ! bde ! org
[Download RAW message or body]


On Fri, 6 Feb 2015, Simon J. Gerraty wrote:

> Anuranjan Shukla <anshukla@juniper.net> wrote:
>> this, along with return value being 'int' acceptable as a final
>> determination?
>
> It is ok for the function to return long,
> so long as an int is used internally.
> Casting the int to long - implicit on return does no harm.
>
> #include <stdio.h>
> #include <sys/types.h>
> #include <unistd.h>
>
> int
> main(int argc, char *argv[])
> {
>    uint a, b;
>    long r1;
>    int r2;
>
>    a = 1;
>    b = 2;
>
>    r1 = a - b;
>    r2 = a - b;
>
>    printf("r1=%ld\nr2=%d\nr3=%ld\n", r1, r2, (long)r2);
>    exit(0);
> }
>
> r1=4294967295
> r2=-1
> r3=-1
>
> so I think just using 'int' internally should work for now,
> perhaps with a comment saying the object size should match
> those being subtracted etc.

Yes, that is simplest.

Bruce
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic