nice error report on opposite condition

View: New views
2 Messages — Rating Filter:   Alert me  

nice error report on opposite condition

by Håkan Johansson-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi,

When running gpsd as root, it successfully changes the priority with
nice(), and produces an error message: Priority setting failed.
When trying failure as non-root (circumventing the getuid() check), the
priority is not changed, and no error message is generated.

-       if (nice(NICEVAL) != -1 || errno == 0)
             gpsd_report (2, "Priority setting failed.\n");

should be

+       if (nice(NICEVAL) == -1 && errno != 0)
             gpsd_report (2, "Priority setting failed.\n");

from man nice(2):

RETURN VALUE
        On success, the new nice value is returned (but see NOTES below).
        On error, -1 is returned, and errno is set appropriately.

(Notes is about -1 being a possibly successful return.  Well, not with
NICEVAL -10 but anyhow.)

Cheers,
Håkan
_______________________________________________
Gpsd-dev mailing list
Gpsd-dev@...
https://lists.berlios.de/mailman/listinfo/gpsd-dev

Re: nice error report on opposite condition

by Gary E. Miller :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yo Håkan!

Nice catch.  Fixed in svn r6466.  Sorry, I could not figure out the
UTF-8 for your proper name in the comment.

RGDS
GARY
- ---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97701
        gem@...  Tel:+1(541)382-8588

On Thu, 12 Nov 2009, Håkan Johansson wrote:

> Date: Thu, 12 Nov 2009 20:57:09 +0100
> From: Håkan Johansson <f96hajo@...>
> Reply-To: gpsd-dev@...
> To: gpsd-dev@...
> Subject: [Gpsd-dev] nice error report on opposite condition
>
>
> Hi,
>
> When running gpsd as root, it successfully changes the priority with nice(),
> and produces an error message: Priority setting failed.
> When trying failure as non-root (circumventing the getuid() check), the
> priority is not changed, and no error message is generated.
>
> -       if (nice(NICEVAL) != -1 || errno == 0)
>             gpsd_report (2, "Priority setting failed.\n");
>
> should be
>
> +       if (nice(NICEVAL) == -1 && errno != 0)
>             gpsd_report (2, "Priority setting failed.\n");
>
> from man nice(2):
>
> RETURN VALUE
>        On success, the new nice value is returned (but see NOTES below).
>        On error, -1 is returned, and errno is set appropriately.
>
> (Notes is about -1 being a possibly successful return.  Well, not with NICEVAL
> -10 but anyhow.)
>
> Cheers,
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFK/IyjBmnRqz71OvMRAqGmAJwOExuiv1nWL2pUagjWKTQeJXFOwgCgjol3
Dwp9FJ/+KKs+2dgn1ETsJRc=
=k5CA
-----END PGP SIGNATURE-----

_______________________________________________
Gpsd-dev mailing list
Gpsd-dev@...
https://lists.berlios.de/mailman/listinfo/gpsd-dev