On Mon, Apr 20, 2015 at 04:43:20PM +0200, Lennart Poettering wrote: > On Tue, 14.04.15 21:58, Zbigniew Jędrzejewski-Szmek ([email protected]) 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? I thought the visual difference between the capitalized names and what we used so far is too big: e.g. ADD_USER and <audit-1114>, and it is better to have something visually similar at least. > Also, may turn this into a macro expression using ({}) that returns > this as alloca() allocated string? You mean the whole function? I'll try that. The only downside is it cannot be called directly in the args to another function.
> > +} > > 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 (). OK. > > +const char *audit_type_name(int type, > > + char buf[AUDIT_NAME_BUF_SIZE]); OK. Thanks for the review, I'll submit another version. Zbyszek _______________________________________________ systemd-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/systemd-devel
