mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dasdinfo: Drop obsolete kernel check and use errx() for arg errors
Remove the uname()/sscanf()-based kernel version gate (Linux < 2.6), which is long obsolete and does not belong in user-space argument validation. While touching the code, replace the repeated warnx() + exit(1) pattern with errx(EXIT_FAILURE, ...) in the option sanity checks to reduce boilerplate and keep error paths consistent. Behaviour is unchanged for supported environments; the version gate is dropped because it is obsolete. Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com> Signed-off-by: Jan Polensky <japo@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
06984cd9ee
commit
7093a70b51
@@ -550,8 +550,6 @@ static int dinfo_get_uid_from_devnode(char **uidfile, char *devnode)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
struct utsname uname_buf;
|
||||
int version, release;
|
||||
char *uidfile = NULL;
|
||||
char *device = NULL;
|
||||
char *readbuf = NULL;
|
||||
@@ -616,29 +614,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
uname(&uname_buf);
|
||||
sscanf(uname_buf.release, "%d.%d", &version, &release);
|
||||
if (strcmp(uname_buf.sysname, "Linux") ||
|
||||
version < 2 || (version == 2 && release < 6)) {
|
||||
warnx("%s %d.%d is not supported", uname_buf.sysname,
|
||||
version, release);
|
||||
exit(1);
|
||||
}
|
||||
if (!busid && !blockdev && !devnode)
|
||||
errx(EXIT_FAILURE, "Error: please specify a device using either -b, -i or -d");
|
||||
|
||||
if (!busid && !blockdev && !devnode) {
|
||||
warnx("Error: please specify a device using either -b, -i or -d");
|
||||
exit(1);
|
||||
}
|
||||
if ((busid && blockdev) || (busid && devnode) || (blockdev && devnode))
|
||||
errx(EXIT_FAILURE, "Error: please specify device only once, either -b, -i or -d");
|
||||
|
||||
if ((busid && blockdev) || (busid && devnode) || (blockdev && devnode)) {
|
||||
warnx("Error: please specify device only once, either -b, -i or -d");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!print_uid && !print_extended_uid && !print_vlabel) {
|
||||
warnx("Error: no action specified (e.g. -u)");
|
||||
exit(1);
|
||||
}
|
||||
if (!print_uid && !print_extended_uid && !print_vlabel)
|
||||
errx(EXIT_FAILURE, "Error: no action specified (e.g. -u)");
|
||||
|
||||
readbuf = dinfo_malloc(RD_BUFFER_SIZE);
|
||||
if (!readbuf)
|
||||
|
||||
Reference in New Issue
Block a user