OSDN Git Service

maint: placate coverity: don't ignore some return values
authorJim Meyering <meyering@redhat.com>
Mon, 30 May 2011 11:09:01 +0000 (13:09 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 30 May 2011 11:09:01 +0000 (13:09 +0200)
* libparted/cs/constraint.c: Include <assert.h>.
(ped_constraint_exact): Don't ignore ped_alignment_init's return
value or that from ped_geometry_init.

libparted/cs/constraint.c

index f4181c5..e0f4c4d 100644 (file)
@@ -46,6 +46,7 @@
 #include <config.h>
 #include <parted/parted.h>
 #include <parted/debug.h>
+#include <assert.h>
 
 /**
  * Initializes a pre-allocated piece of memory to contain a constraint
@@ -511,11 +512,20 @@ ped_constraint_exact (const PedGeometry* geom)
        PedAlignment    end_align;
        PedGeometry     start_sector;
        PedGeometry     end_sector;
-
-       ped_alignment_init (&start_align, geom->start, 0);
-       ped_alignment_init (&end_align, geom->end, 0);
-       ped_geometry_init (&start_sector, geom->dev, geom->start, 1);
-       ped_geometry_init (&end_sector, geom->dev, geom->end, 1);
+       int ok;
+
+       /* With grain size of 0, it always succeeds.  */
+       ok = ped_alignment_init (&start_align, geom->start, 0);
+       assert (ok);
+       ok = ped_alignment_init (&end_align, geom->end, 0);
+       assert (ok);
+
+       ok = ped_geometry_init (&start_sector, geom->dev, geom->start, 1);
+       if (!ok)
+         return NULL;
+       ok = ped_geometry_init (&end_sector, geom->dev, geom->end, 1);
+       if (!ok)
+         return NULL;
 
        return ped_constraint_new (&start_align, &end_align,
                                   &start_sector, &end_sector, 1,