On Sun, May 20, 2012 at 06:11:36PM +0200, Davidlohr Bueso wrote: > +struct fdisk_context *fdisk_new_context_from_filename(const char *fname) > +{ > + int fd; > + struct fdisk_context *cxt = NULL; > + > + /* > + * Attempt to open the device with r-w permissions > + * by default, otherwise try read-only. > + */ > + if ((fd = open(fname, O_RDWR)) < 0) > + if ((fd = open(fname, O_RDONLY)) < 0) > + goto ret; return NULL; > + cxt = calloc(1, sizeof(*cxt)); > + if (!cxt) > + goto ret; > + > + cxt->dev_fd = fd; > + cxt->dev_path = strdup(fname); > + if (!cxt->dev_path) > + return NULL; goto fail; Please, think about it as about library, it meas without memory and fd leaks :-) > +ret: > + return cxt; > +} > + return cxt; fail: errsv = errno; fdisk_free_context(cxt); errno = errsv; return NULL; 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