Ethereal-dev: [Ethereal-dev] Why does prefs_register_enum_preference use type gint and not typ

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Ulf Lamping <ulf.lamping@xxxxxx>
Date: Mon, 27 Dec 2004 11:09:17 +0100
Hi List!

Is there a reason, that the var parameter of the prefs_register_enum_preference() function in epan/prefs.h is of type gint and not of type enum (as I would expected it)?

typedef struct {
    char    *name;
    char    *description;
    gint    value;
} enum_val_t;

extern void prefs_register_enum_preference(module_t *module, const char *name,
    const char *title, const char *description, gint *var,
    const enum_val_t *enumvals, gboolean radio_buttons);

This causes some gcc warnings, like:
packet-m2pa.c: In function `proto_register_m2pa':
packet-m2pa.c:576: warning: dereferencing type-punned pointer will break strict-aliasing rules

IMHO it should look like the following (the changes in bold):

typedef struct {
    char    *name;
    char    *description;
    enum    value;
} enum_val_t;

extern void prefs_register_enum_preference(module_t *module, const char *name,
    const char *title, const char *description, enum *var,
    const enum_val_t *enumvals, gboolean radio_buttons);

Of course, the calling functions in other dissectors should also use "a real enum" instead of the current gint.

Regards, ULFL