NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/53495: sched_get_priority_max/sched_get_priority_min not returning useful values



The following reply was made to PR lib/53495; it has been noted by GNATS.

From: Kamil Rytarowski <n54%gmx.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: 
Subject: Re: lib/53495: sched_get_priority_max/sched_get_priority_min not
 returning useful values
Date: Fri, 3 Aug 2018 03:51:30 +0200

 This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
 --7wkq1Z49HiEpb7JPjpaGGal6r1brtfhzd
 Content-Type: multipart/mixed; boundary="tiwuuZY8nB3YFgWVuGrDuw6DMCE9AkLs5";
  protected-headers="v1"
 From: Kamil Rytarowski <n54%gmx.com@localhost>
 To: gnats-bugs%NetBSD.org@localhost
 Message-ID: <b103caed-06e4-5267-315b-5a2504955dc8%gmx.com@localhost>
 Subject: Re: lib/53495: sched_get_priority_max/sched_get_priority_min not
  returning useful values
 References: <pr-lib-53495%gnats.netbsd.org@localhost>
  <20180802213550.3008D2AC0E7%yt.nih.at@localhost>
  <20180802214000.8D1F77A14F%mollari.NetBSD.org@localhost>
 In-Reply-To: <20180802214000.8D1F77A14F%mollari.NetBSD.org@localhost>
 
 --tiwuuZY8nB3YFgWVuGrDuw6DMCE9AkLs5
 Content-Type: text/plain; charset=utf-8
 Content-Language: en-US
 Content-Transfer-Encoding: quoted-printable
 
 This is not a bug. It works as intended.
 
 NetBSD behavior is compliant with POSIX and 3rd party program has to be
 fixed and handle the -1 case on its own, if there is need to distinguish
 error and unsupported, there is an option to reset errno and check it
 after the call.
 
 On 02.08.2018 23:40, Thomas Klausner wrote:
 >> Number:         53495
 >> Category:       lib
 >> Synopsis:       sched_get_priority_max/sched_get_priority_min not retu=
 rning useful values
 >> Confidential:   no
 >> Severity:       serious
 >> Priority:       low
 >> Responsible:    lib-bug-people
 >> State:          open
 >> Class:          sw-bug
 >> Submitter-Id:   net
 >> Arrival-Date:   Thu Aug 02 21:40:00 +0000 2018
 >> Originator:     Thomas Klausner
 >> Release:        NetBSD 8.99.22
 >> Organization:
 > Curiosity is the very basis of education and if you tell me that=20
 > curiosity killed the cat, I say only that the cat died nobly.
 > - Arnold Edinborough
 >> Environment:
 > =09
 > =09
 > Architecture: x86_64
 > Machine: amd64
 >> Description:
 > The man page describes the functions as follows:
 >=20
 >      sched_get_priority_max(policy)
 >               Returns the maximal priority which may be used for the
 >               scheduling policy specified by policy.
 >=20
 >      sched_get_priority_min(policy)
 >               Returns the minimal priority which may be used for the
 >               scheduling policy specified by policy.
 >=20
 > and later:
 >=20
 >      sched_get_priority_max() and sched_get_priority_min() return the
 >      maximal/minimal priority value on success.  Otherwise, -1 is retur=
 ned and
 >      errno is set to indicate the error.
 >=20
 > So programs check for "-1" to detect errors.
 >=20
 > However, in NetBSD, -1 is also returned in other cases, see
 > /usr/src/lib/libc/sys/sched.c:
 >=20
 > int
 > sched_get_priority_min(int policy)
 > {
 >=20
 >         switch (policy) {
 >         case SCHED_OTHER:
 >                 return PRI_NONE;
 >         case SCHED_RR:
 >         case SCHED_FIFO:
 >                 return (int)sysconf(_SC_SCHED_PRI_MIN);
 >         default:
 >                 errno =3D EINVAL;
 >                 return -1;
 >         }
 > }
 >=20
 >=20
 > and
 >=20
 > /usr/include/sys/param.h:#define        PRI_NONE                (-1)
 >=20
 > I'm not sure what the correct fix is. I suggest returning 0 instead of =
 -1;
 > I don't know what the definition of PRI_NONE is supposed to be and if t=
 hat
 > should be changed, or if the return value should just be zero for both
 > functions and not use PRI_NONE.
 >=20
 >> How-To-Repeat:
 >=20
 > #include <sched.h>
 > int main() {
 > printf("%d-%d\n", sched_get_priority_max(0), sched_get_priority_min(0))=
 ;
 > }
 >=20
 > gives:
 >=20
 > -1--1
 >=20
 >=20
 > Worse, wxGTK30 pops up unnecessary error messages at runtime.
 >=20
 >> Fix:
 > Return 0, and/or redefine PRI_NONE.
 >=20
 >> Unformatted:
 >  =09
 >  =09
 >=20
 
 
 
 --tiwuuZY8nB3YFgWVuGrDuw6DMCE9AkLs5--
 
 --7wkq1Z49HiEpb7JPjpaGGal6r1brtfhzd
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 
 iQJABAEBCAAqFiEELaxVpweEzw+lMDwuS7MI6bAudmwFAltjtSIMHG41NEBnbXgu
 Y29tAAoJEEuzCOmwLnZslF8P/3Q0Vbv8GjJshCmsiRfWjsefvz/bLal4qIReXsz/
 qa+ERQRrvBHYUndmiHz7UoAsFzpflr3nUJ1L0FD5fdWwNPfzqBhzqbAuYUTns4XZ
 WJwDt8LLFgxsKOSlDmC7EORD5+HSz0pne2pFoFUKc8ISRqZ/19ZZbUL0VpQHldUb
 jfWdHvgoNTdNIpXNeIwekcLEoQpjRd53jNnu0WANXA0XOroEAdBVJ1Mj2IiFeoJu
 BGyq1RZCQlcFTn7Zi/34Y8dIt2jwc8f0T38564226kBwyuGutUWOqUbyPAnrzHVy
 pF3MAqvklqPY//EAASiBhWrFEyZPZWuKFty+iulVlWUXlFFFSlTz34HlNvkB6BXF
 1vytwXuGs2gJ7rYZJU1HC/mbHd6dInsL+77Z3wWZ1uPzNlzA+gE1Ak8hwYQ9EZlE
 GUo80XvlASzMbn8bRRdUs19Upnpwltpla5XSagML3YZY1e8LcogETWOHZmLczpZe
 9yuxE/Lo19FbgIuh6MZQV2Ptt+DNabmFrZThBkJ8+kB81WuNSt7DJxblTaYDrslK
 MqJ+Wkv047ytT8Q8mfa0djCdhpE61/dbob9uLscab+xey948qCWE3R28Ab6DTI8K
 9tTUhKa5YyVGr5ldRGr3jNp44I7pVFZ99CjbCJFuV89m6gJL+W+kKnS2pT0SWUpU
 Xlxf
 =PpAf
 -----END PGP SIGNATURE-----
 
 --7wkq1Z49HiEpb7JPjpaGGal6r1brtfhzd--
 


Home | Main Index | Thread Index | Old Index