Bug 14347 - LOG_MAKEPRI needs LOG_FAC, or should not shift
Summary: LOG_MAKEPRI needs LOG_FAC, or should not shift
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.16
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2012-07-10 15:55 UTC by Rasmus Villemoes
Modified: 2023-06-18 23:47 UTC (History)
4 users (show)

See Also:
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Rasmus Villemoes 2012-07-10 15:55:22 UTC
The two examples of use of the LOG_MAKEPRI macro in the manual for 2.16 (and earlier) are broken. The facility macros LOG_USER, ..., LOG_LOCAL1, ... already contain a left-shift of 3, so to use these macros in LOG_MAKEPRI (which also makes a shift), that shift has to be undone by using the LOG_FAC macro. The example at the end of 18.2.2 would then be something like

            "Unable to make network connection to %s. Error=%m", host);

Alternatively, the documentation could drop mentioning the LOG_MAKEPRI macro at all and simply instruct people to OR the facility and priority, resulting in the much simpler

    syslog (LOG_LOCAL1 | LOG_ERROR,
            "Unable to make network connection to %s. Error=%m", host);

(Alternatively, this is a bug against the LOG_MAKEPRI macro, which should simply do exactly this, but this would break code which uses the LOG_FAC macro.)
Comment 1 Andreas Schwab 2012-07-10 16:55:17 UTC
This bug was fixed 15 years ago in BSD <http://svnweb.freebsd.org/base?view=revision&revision=23252>, glibc should follow.
Comment 2 Andreas Schwab 2012-07-10 20:41:21 UTC
Fixed in 2.17.