]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: cleanup internal return codes
authorKarel Zak <kzak@redhat.com>
Tue, 10 Jun 2014 11:32:02 +0000 (13:32 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 10 Jun 2014 11:32:02 +0000 (13:32 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/partitions/partitions.c
libblkid/src/superblocks/superblocks.c
libblkid/src/topology/topology.c

index cee963ff6d1eaf1cdd128c11deac10a51b6dc8e9..04c75afa780386a65a9d5dcb06d0d5c953fddb40 100644 (file)
@@ -536,7 +536,7 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id,
 {
        const struct blkid_idmag *mag = NULL;
        blkid_loff_t off;
-       int rc = BLKID_PROBE_NONE;              /* = nothing detected */
+       int rc = BLKID_PROBE_NONE;              /* default is nothing */
 
        if (pr->size <= 0 || (id->minsz && id->minsz > pr->size))
                goto nothing;   /* the device is too small */
@@ -567,8 +567,10 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id,
                DBG(LOWPROBE, ul_debug("%s: <--- (rc = %d)", id->name, rc));
        }
 
-nothing:
        return rc;
+
+nothing:
+       return BLKID_PROBE_NONE;
 }
 
 /*
@@ -581,11 +583,12 @@ static int partitions_probe(blkid_probe pr, struct blkid_chain *chn)
 
        if (!pr || chn->idx < -1)
                return -EINVAL;
-       if (pr->flags & BLKID_FL_NOSCAN_DEV)
-               goto done;                      /* nothing */
 
        blkid_probe_chain_reset_vals(pr, chn);
 
+       if (pr->flags & BLKID_FL_NOSCAN_DEV)
+               return BLKID_PROBE_NONE;
+
        if (chn->binary)
                partitions_init_data(chn);
 
@@ -627,7 +630,7 @@ static int partitions_probe(blkid_probe pr, struct blkid_chain *chn)
 
                DBG(LOWPROBE, ul_debug("<-- leaving probing loop (type=%s) [PARTS idx=%d]",
                        name, chn->idx));
-               rc = 0;
+               rc = BLKID_PROBE_OK;
                break;
        }
 
@@ -653,7 +656,6 @@ details_only:
                        rc = xrc;
        }
 
-done:
        DBG(LOWPROBE, ul_debug("partitions probe done [rc=%d]", rc));
        return rc;
 }
@@ -723,7 +725,6 @@ int blkid_partitions_do_subprobe(blkid_probe pr, blkid_partition parent,
 
 static int blkid_partitions_probe_partition(blkid_probe pr)
 {
-       int rc = BLKID_PROBE_NONE;
        blkid_probe disk_pr = NULL;
        blkid_partlist ls;
        blkid_partition par;
@@ -748,7 +749,9 @@ static int blkid_partitions_probe_partition(blkid_probe pr)
                goto nothing;
 
        par = blkid_partlist_devno_to_partition(ls, devno);
-       if (par) {
+       if (!par)
+               goto nothing;
+       else {
                const char *v;
                blkid_parttable tab = blkid_partition_get_table(par);
                dev_t disk = blkid_probe_get_devno(disk_pr);
@@ -794,10 +797,15 @@ static int blkid_partitions_probe_partition(blkid_probe pr)
                blkid_probe_sprintf_value(pr, "PART_ENTRY_DISK", "%u:%u",
                                major(disk), minor(disk));
        }
-       rc = BLKID_PROBE_OK;
+
+       DBG(LOWPROBE, ul_debug("parts: end probing for partition entry [success]"));
+       return BLKID_PROBE_OK;
+
 nothing:
-       DBG(LOWPROBE, ul_debug("parts: end probing for partition entry [rc=%d]", rc));
-       return rc;
+       DBG(LOWPROBE, ul_debug("parts: end probing for partition entry [nothing]"));
+       return BLKID_PROBE_NONE;
+
+
 }
 
 /*
index bfe37b85d2bd21744ca9ff8217409fc076d8ce02..80bd6e596f3d0d42465acd17c353340256259e46 100644 (file)
@@ -340,19 +340,20 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
 
        if (!pr || chn->idx < -1)
                return -EINVAL;
-       if (pr->flags & BLKID_FL_NOSCAN_DEV)
-               goto nothing;
 
        blkid_probe_chain_reset_vals(pr, chn);
 
-       DBG(LOWPROBE, ul_debug("--> starting probing loop [SUBLKS idx=%d]",
-               chn->idx));
+       if (pr->flags & BLKID_FL_NOSCAN_DEV)
+               return BLKID_PROBE_NONE;
 
        if (pr->size <= 0 || (pr->size <= 1024 && !S_ISCHR(pr->mode)))
                /* Ignore very very small block devices or regular files (e.g.
                 * extended partitions). Note that size of the UBI char devices
                 * is 1 byte */
-               goto nothing;
+               return BLKID_PROBE_NONE;
+
+       DBG(LOWPROBE, ul_debug("--> starting probing loop [SUBLKS idx=%d]",
+               chn->idx));
 
        i = chn->idx < 0 ? 0 : chn->idx + 1U;
 
@@ -422,7 +423,7 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
                                        (unsigned char *) mag->magic);
                if (rc) {
                        blkid_probe_chain_reset_vals(pr, chn);
-                       DBG(LOWPROBE, ul_debug("failed to set result -- ingnore"));
+                       DBG(LOWPROBE, ul_debug("failed to set result -- ignore"));
                        continue;
                }
 
@@ -431,7 +432,6 @@ static int superblocks_probe(blkid_probe pr, struct blkid_chain *chn)
                return BLKID_PROBE_OK;
        }
 
-nothing:
        DBG(LOWPROBE, ul_debug("<-- leaving probing loop (failed=%d) [SUBLKS idx=%d]",
                        rc, chn->idx));
        return rc;
@@ -459,13 +459,12 @@ static int superblocks_safeprobe(blkid_probe pr, struct blkid_chain *chn)
        int rc;
 
        if (pr->flags & BLKID_FL_NOSCAN_DEV)
-               return 1;                               /* nothing */
+               return BLKID_PROBE_NONE;
 
        while ((rc = superblocks_probe(pr, chn)) == 0) {
 
                if (blkid_probe_is_tiny(pr) && !count)
-                       /* floppy or so -- returns the first result. */
-                       return 0;
+                       return BLKID_PROBE_OK;  /* floppy or so -- returns the first result. */
 
                count++;
 
@@ -494,7 +493,7 @@ static int superblocks_safeprobe(blkid_probe pr, struct blkid_chain *chn)
                return -2;              /* error, ambivalent result (more FS) */
        }
        if (!count)
-               return 1;               /* nothing detected */
+               return BLKID_PROBE_NONE;
 
        if (idx != -1) {
                /* restore the first result */
@@ -511,7 +510,7 @@ static int superblocks_safeprobe(blkid_probe pr, struct blkid_chain *chn)
        if (chn->idx >= 0 && idinfos[chn->idx]->usage & BLKID_USAGE_RAID)
                pr->prob_flags |= BLKID_PROBE_FL_IGNORE_PT;
 
-       return 0;
+       return BLKID_PROBE_OK;
 }
 
 int blkid_probe_set_version(blkid_probe pr, const char *version)
index a6a7a3bd523689109a6e3bf22898575f7f4bdc2a..93fa3802e5efc37b717f428c27a8b69aa14218da 100644 (file)
@@ -150,7 +150,7 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn)
                return -1;
 
        if (!S_ISBLK(pr->mode))
-               return -1;      /* nothing, works with block devices only */
+               return -EINVAL; /* nothing, works with block devices only */
 
        if (chn->binary) {
                DBG(LOWPROBE, ul_debug("initialize topology binary data"));
@@ -163,7 +163,7 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn)
                        chn->data = calloc(1,
                                        sizeof(struct blkid_struct_topology));
                        if (!chn->data)
-                               return -1;
+                               return -ENOMEM;
                }
        }
 
@@ -193,12 +193,12 @@ static int topology_probe(blkid_probe pr, struct blkid_chain *chn)
 
                DBG(LOWPROBE, ul_debug("<-- leaving probing loop (type=%s) [TOPOLOGY idx=%d]",
                        id->name, chn->idx));
-               return 0;
+               return BLKID_PROBE_OK;
        }
 
        DBG(LOWPROBE, ul_debug("<-- leaving probing loop (failed) [TOPOLOGY idx=%d]",
                chn->idx));
-       return 1;
+       return BLKID_PROBE_NONE;
 }
 
 static void topology_free(blkid_probe pr __attribute__((__unused__)),