[systemd-devel] [PATCH 2/3] journal: use audit event names instead of numbers

Lennart Poettering lennart at poettering.net
Mon Apr 20 07:43:20 PDT 2015


On Tue, 14.04.15 21:58, Zbigniew Jędrzejewski-Szmek (zbyszek at in.waw.pl) wrote:

> +const char *audit_type_name(int type,
> +                            char buf[AUDIT_NAME_BUF_SIZE]) {
> +        const char *s;
> +
> +        s = audit_type_to_string(type);
> +        if (s)
> +                return s;
> +
> +        /* This is inspired by DNS TYPEnnn formatting */
> +        snprintf(buf, AUDIT_NAME_BUF_SIZE, "AUDIT%04i", type);
> +        return buf;

Shouldn't we stick to <audit-xyz> at least, to stay congruent to what
we so far did, at least for the unknown ones?

Also, may turn this into a macro expression using ({}) that returns
this as alloca() allocated string? 


> +}
> diff --git src/journal/audit-type.h src/journal/audit-type.h
> index 9f37716cd6..a2c98cee80 100644
> --- src/journal/audit-type.h
> +++ src/journal/audit-type.h
> @@ -21,6 +21,11 @@
>    along with systemd; If not, see <http://www.gnu.org/licenses/>.
>  ***/
>  
> +#include "macro.h"
>  
>  const char *audit_type_to_string(int type);
>  int audit_type_from_string(const char *s);
> +
> +#define AUDIT_NAME_BUF_SIZE sizeof("AUDIT")-1 +
>  DECIMAL_STR_MAX(int)

Will break if people use expressions like 3*AUDIT_NAME_BUF_SIZE, since
it is missing the surrounding ().

> +const char *audit_type_name(int type,
> +                            char buf[AUDIT_NAME_BUF_SIZE]);

Weird line break...

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list