int main(int argc, char **argv) { _cleanup_udev_unref_ struct udev *udev; int retval = 0; char maj_min_dev[MAX_PATH_LEN]; int newargc; char **newargv = NULL; log_open(); udev = udev_new(); if (udev == NULL) goto exit; udev_set_log_fn(udev, log_fn); /* * Get config file options. */ retval = get_file_options(udev, NULL, NULL, &newargc, &newargv); if (retval < 0) { retval = 1; goto exit; } if (retval == 0) { assert(newargv); if (set_options(udev, newargc, newargv, maj_min_dev) < 0) { retval = 2; goto exit; } } /* * Get command line options (overriding any config file settings). */ if (set_options(udev, argc, argv, maj_min_dev) < 0) exit(1); if (!dev_specified) { log_error("no device specified"); retval = 1; goto exit; } retval = scsi_id(udev, maj_min_dev); exit: if (newargv) { free(newargv[0]); free(newargv); } log_close(); return retval; }
int main(int argc, char **argv) { int retval = 0; char maj_min_dev[MAX_PATH_LEN]; int newargc; char **newargv = NULL; log_set_target(LOG_TARGET_AUTO); udev_parse_config(); log_parse_environment(); log_open(); /* * Get config file options. */ retval = get_file_options(NULL, NULL, &newargc, &newargv); if (retval < 0) { retval = 1; goto exit; } if (retval == 0) { assert(newargv); if (set_options(newargc, newargv, maj_min_dev) < 0) { retval = 2; goto exit; } } /* * Get command line options (overriding any config file settings). */ if (set_options(argc, argv, maj_min_dev) < 0) exit(EXIT_FAILURE); if (!dev_specified) { log_error("No device specified."); retval = 1; goto exit; } retval = scsi_id(maj_min_dev); exit: if (newargv) { free(newargv[0]); free(newargv); } log_close(); return retval; }