On Wed, Mar 19, 2014 at 02:50:56PM +0100, Hannes Reinecke wrote: > --- a/libblkid/src/partitions/bsd.c > +++ b/libblkid/src/partitions/bsd.c > @@ -42,14 +42,18 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag) > return 0; > > data = blkid_probe_get_sector(pr, BLKID_MAG_SECTOR(mag)); > - if (!data) > - goto nothing; > + if (!data) { > + if (errno) > + goto err; > + else > + goto nothing; > + } It would be nice to return the error code (-errno) from the function. Maybe you can use something like: int rc = 1; /* default is nothing */ data = blkid_probe_get_sector(pr, BLKID_MAG_SECTOR(mag)); if (!data) { rc = error ? -errno : 1; goto done; } ... rc = 0; /* success, all probing stuff pass */ done: return rc; to reduce number of the code lines and number of goto labels and to return the proper return code. > ls = blkid_probe_get_partlist(pr); > if (!ls) > - goto err; > + goto nothing; hmm.. it usually means malloc() error, I have doubts we want to ignore such errors, it would be probably better to return -ENOMEM in this case. if (!ls) { rc = -ENOMEM; goto done; } If you do the cleanup then do it for all errors, not for I/O only ;-) > + if (!data) { > + if (errno) > + goto err; > + else > + goto leave; /* malformed partition? */ > + } BTW, "else" after "goto" is probably unnecessary, just if (foo) goto y; goto x; Karel -- Karel Zak <kzak@xxxxxxxxxx> http://karelzak.blogspot.com -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html