[parted-devel] [PATCH] Properly sync partitions with operating system

Jim Meyering jim at meyering.net
Thu Mar 5 17:37:55 UTC 2009


Karel Zak wrote:
> On Wed, Feb 25, 2009 at 11:59:33PM +0100, Joel Granados Moreno wrote:
>> +static unsigned int
>> +_device_get_partition_range(PedDevice* dev)
>> +{
>> +        int         range, r;
>> +        char        path[128];
>> +        FILE*       fp;
>> +        bool        ok;
>> +
>> +        r = snprintf(path, sizeof(path), "/sys/block/%s/range",
>> +                        basename(dev->path));
>
>  always _GNU_SOURCE, right? :-)

Good portability catch.
There are actually two uses of basename.
I'll convert them to base_name or last_component
(provided by gnulib's basename module).

>> +        if(r < 0 || r > sizeof(path))
>> +                return MAX_NUM_PARTS;
>
>             if(r < 0 || r >= sizeof(path))
>
>  the return value does not including the trailing '\0', see man page:
>
>     Thus, a return value of size or more means that the
>     output was truncated.

Thanks, Karel.
I've just pushed this:



More information about the parted-devel mailing list