Re: [PATCH 3/4 V2] chrt: simplify the other check for too few arguments

Benno Schulenberg <[email protected]> Sun, 6 Jul 2025 11:10:04 +0200
Newsgroups org.kernel.vger.util-linux
Message-ID <[email protected]>
Op 06-07-2025 om 07:58 schreef Madadi Vineeth Reddy:
> But priority should also be optional when --pid is not used, for
> policies that don’t require it.

Oh...  Then the synopses need adjusting, because currently they
indicate the priority value as mandatory when a command is given:

   chrt [options] priority command [argument...]


> With your patch, this fails:
> chrt --other ls
> chrt: too few arguments
> Try 'chrt --help' for more information.
> 
> while this works:
> chrt --other 0 ls
> 
> The first case should work too, to match the behavior introduced in
> commit e7a2d62434c2 ("chrt: Make priority optional for policies that don't use it").

With current git (or after checking out that commit), and then running
`./chrt --other ls`, it says here:

   Segmentatiefout (geheugendump gemaakt)

Running valgrind on it gives:

   ==38370== Invalid read of size 1
   ==38370==    by 0x10C6EB: main (chrt.c:574)

Pointing to: if (strcmp(argv[0], "--") == 0)


Benno
OpenPGP_signature.asc (application/pgp-signature, 840 B)
-----BEGIN PGP SIGNATURE-----

wsF5BAABCAAjFiEEFo5vQpe/16ea/USWUUu+Lrjhlh8FAmhqPWwFAwAAAAAACgkQUUu+Lrjhlh/a
MxAA2W6xbCPkF0WXoqbGP8IHDE8gd1J7Aed+7JStqamXDjgBmBw0LAPrqTpozvWRAR0BW9iDj0L1
j01rNQxt7mjWwYhNDU9vNR1kcpgWMkWdZ6pNmvl7tAAtTfr4+/gX9aDcNUWdadbDKbsKEcjeQ++1
ZuYFN63UaykmHdvXDXpTOmS8VZsie4JsDo/j9Ybwztumw8szo3jxd+o7UxJCG3BanQBb9zyo13J3
K7Pu5h8t9OuQP+NGnHoyo1WUYdbEzKguKILJUYuAvz/1uI571/BCBJhOACGPfQcikEqzogZgp11b
wQaoYdlAtVMd85bpe32+BO2R142tOGByh8yHE8EEYbnl9G3E116vd9D79TmFxAruaAM7HGBSSky0
JUF7OZUjUluxAcj3paWU+pfIcykl//IJjEf0n9APRp6qFzMQCGUOsnYGdEJ0pZF+oQoZnORNnqY5
eyBZI/Smy/lajZawkiMlE1Bh0dTW6RhBysHoPe13UErmlCy1Ju/0F0GQVRdKv9KeSTE1I017PDIq
K3FrE6EVdZtGVNIgC5Ad7Enfk6sroMePhlfNFOJv6fIGxYYKt53qg9FpW4gaOKVy3XNF3eidO5So
fG26NLWhDBH0juALeCfpNuJdeZGzTCzSkgGPgjWS5fDuEuUZlMCSsapA2P0AaWKuBKsvXllwoml2
GOM=
=KNgF
-----END PGP SIGNATURE-----