Otavio Salvador <[EMAIL PROTECTED]> wrote:

> Jim Meyering <[EMAIL PROTECTED]> writes:
>
>> FYI:
>>
>>      tests/label: Don't dereference NULL if open fails.
>>      * libparted/tests/label.c (START_TEST): Return right away if
>>      ped_device_get returns NULL.
>>
>> diff --git a/libparted/tests/label.c b/libparted/tests/label.c
>> index f12e4c8..c043e37 100644
>> --- a/libparted/tests/label.c
>> +++ b/libparted/tests/label.c
>> @@ -26,6 +26,8 @@ static void destroy_disk(void)
>>  START_TEST (test_create_label)
>>  {
>>              PedDevice *dev = ped_device_get(temporary_disk);
>> +            if (dev == NULL)
>> +                    return;
>
>
> Wouldn't be better to fail?

Oops.  I nearly replied like this:

  That's already done by the caller,
  just before returning NULL.

but we're talking about ped_device_get, not create_disk.

So you're right.
Thanks.  Here's what I'll check in after testing:

        * libparted/tests/label.c: Use fail_if rather than just returning.
        Spotted by Otavio Salvador.

diff --git a/libparted/tests/label.c b/libparted/tests/label.c
index c043e37..ee6d0cd 100644
--- a/libparted/tests/label.c
+++ b/libparted/tests/label.c
@@ -26,8 +26,7 @@ static void destroy_disk(void)
 START_TEST (test_create_label)
 {
                PedDevice *dev = ped_device_get(temporary_disk);
-               if (dev == NULL)
-                       return;
+               fail_if(dev == NULL, "Failed to get a device handle");
                PedDiskType *type;
                PedDisk *disk;

_______________________________________________
parted-devel mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/parted-devel

Reply via email to