From: Stefan Hajnoczi Date: Wed, 17 Dec 2025 18:26:05 +0000 (-0500) Subject: blkpr: prepare for _IOR() ioctls X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60e0cb106e33a84cb4f1b654754b627e916f24b8;p=thirdparty%2Futil-linux.git blkpr: prepare for _IOR() ioctls parse_pr_command() returns the ioctl command constant for a given command or -1 when the command is unknown. Up until now all ioctl command constants were positive, so the following check worked: if (command < 0) err(EXIT_FAILURE, _("unknown command")); The top two bits of ioctl command constants encode the direction (_IO, _IOR, _IOW, _IOWR). ioctl commands defined with _IOR have negative ioctl command constants. Explicitly check for -1 to differentiate "unknown command" from valid ioctls commands. Later commits will add ioctl commands that use _IOR. Signed-off-by: Stefan Hajnoczi --- diff --git a/sys-utils/blkpr.c b/sys-utils/blkpr.c index 03ca9f7e5..c6b030def 100644 --- a/sys-utils/blkpr.c +++ b/sys-utils/blkpr.c @@ -276,7 +276,7 @@ int main(int argc, char **argv) break; case 'c': command = parse_pr_command(optarg); - if (command < 0) + if (command == -1) err(EXIT_FAILURE, _("unknown command")); break; case 't':