Series:
Reviewed-by: Jeremy Huddleston <jerem...@apple.com>

On Nov 11, 2011, at 22:49, Alan Coopersmith wrote:

> Allows gcc to check printf format strings instead of just giving warnings.
> Since these #defines are only used in config.c, define them directly there,
> instead of in the config.h header that no one else includes.
> 
> Signed-off-by: Alan Coopersmith <alan.coopersm...@oracle.com>
> ---
> os/config.c |   47 ++++++++++++++++++++++-------------------------
> os/config.h |   12 ------------
> 2 files changed, 22 insertions(+), 37 deletions(-)
> 
> diff --git a/os/config.c b/os/config.c
> index 358189a..809a3fa 100644
> --- a/os/config.c
> +++ b/os/config.c
> @@ -106,19 +106,16 @@ static ConfigOptionRec config_options[] = {
>     {NULL, NULL},
> };
> 
> -static const char * const ConfigErrors[] = {
> -    "",
> -    "CONFIG: insufficient memory to load configuration file \"%s\"\n",
> -    "CONFIG: can't open configuration file \"%s\"\n",
> -    "CONFIG: error reading configuration file \"%s\"\n",
> -    "CONFIG: bad value \"%s\" for parameter \"%s\"\n",
> -    "CONFIG: unknown parameter \"%s\"\n",
> -    "CONFIG: missing '=' after parameter \"%s\"\n",
> -    "CONFIG: value out of range for parameter \"%s\"\n",
> -    "CONFIG: syntax error near parameter \"%s\"\n",
> -    "CONFIG: missing value for parameter \"%s\"\n",
> -    "CONFIG: extra value for parameter \"%s\"\n",
> -};
> +#define      CONFIG_ERR_MEMORY "CONFIG: insufficient memory to load 
> configuration file \"%s\"\n"
> +#define      CONFIG_ERR_OPEN "CONFIG: can't open configuration file \"%s\"\n"
> +#define      CONFIG_ERR_READ "CONFIG: error reading configuration file 
> \"%s\"\n"
> +#define      CONFIG_ERR_VALUE "CONFIG: bad value \"%s\" for parameter 
> \"%s\"\n"
> +#define      CONFIG_ERR_UNKNOWN "CONFIG: unknown parameter \"%s\"\n"
> +#define      CONFIG_ERR_NOEQUALS "CONFIG: missing '=' after parameter 
> \"%s\"\n"
> +#define      CONFIG_ERR_RANGE "CONFIG: value out of range for parameter 
> \"%s\"\n"
> +#define      CONFIG_ERR_SYNTAX "CONFIG: syntax error near parameter \"%s\"\n"
> +#define      CONFIG_ERR_NOVALUE "CONFIG: missing value for parameter 
> \"%s\"\n"
> +#define      CONFIG_ERR_EXTRAVALUE "CONFIG: extra value for parameter 
> \"%s\"\n"
> 
> #define       iseol(c)        ((c) == '\n' || (c) == '\r' || (c) == '\f')
> #define       skip_whitespace(c)      while(isspace(*(c)) || *(c) == ',') 
> (c)++;
> @@ -217,14 +214,14 @@ parse_config(char *data)
> 
>       /* check for junk */
>       if (!isspace(*c) && *c != '=') {
> -         ErrorF(ConfigErrors[CONFIG_ERR_SYNTAX], param_name);
> +         ErrorF(CONFIG_ERR_SYNTAX, param_name);
>           /* eat garbage */
>           while (!isspace(*c) && *c != '=' && *c != '\0')
>               c++;
>       }
>       skip_whitespace(c);
>       if (*c != '=') {
> -         ErrorF(ConfigErrors[CONFIG_ERR_NOEQUALS], param_name);
> +         ErrorF(CONFIG_ERR_NOEQUALS, param_name);
>           equals_missing = TRUE;
>       } else {
>           c++;
> @@ -244,26 +241,26 @@ parse_config(char *data)
> 
>           if (val <= c) {
>               /* no value, ignore */
> -             ErrorF(ConfigErrors[CONFIG_ERR_NOVALUE], param_name);
> +             ErrorF(CONFIG_ERR_NOVALUE, param_name);
>               continue;
>           }
>           *val = '\0';
>       } else if (*c == '\0') {
>           /* no value, ignore */
> -         ErrorF(ConfigErrors[CONFIG_ERR_NOVALUE], param_name);
> +         ErrorF(CONFIG_ERR_NOVALUE, param_name);
>           continue;
>       }
>       /* match parm name */
>       if (equals_missing) {
>           equals_missing = FALSE;
>       } else if ((param = match_param_name(param_name)) == NULL) {
> -         ErrorF(ConfigErrors[CONFIG_ERR_UNKNOWN], param_name);
> +         ErrorF(CONFIG_ERR_UNKNOWN, param_name);
>       } else {
>           consumed = (param->set_func) (param, c);
> 
>           skip_whitespace(consumed);
>           if (*consumed != '\0') {
> -             ErrorF(ConfigErrors[CONFIG_ERR_EXTRAVALUE],
> +             ErrorF(CONFIG_ERR_EXTRAVALUE,
>                      param_name);
>           }
>       }
> @@ -331,7 +328,7 @@ ReadConfigFile(const char *filename)
> 
>     data = (char *) fsalloc(CONFIG_MAX_FILESIZE);
>     if (!data) {
> -     ErrorF(ConfigErrors[CONFIG_ERR_MEMORY], filename);
> +     ErrorF(CONFIG_ERR_MEMORY, filename);
>       return FSBadAlloc;
>     }
>     if (filename != NULL) {
> @@ -340,7 +337,7 @@ ReadConfigFile(const char *filename)
> #endif
>       fp = fopen(filename, "r");
>       if (fp == NULL) {
> -         ErrorF(ConfigErrors[CONFIG_ERR_OPEN], filename);
> +         ErrorF(CONFIG_ERR_OPEN, filename);
>       }
>     } else {
>       for (i = 0; default_config_files[i] != NULL; i++) {
> @@ -357,7 +354,7 @@ ReadConfigFile(const char *filename)
>       }
>       if (fp == NULL) {
>           for (i = 0; default_config_files[i] != NULL; i++) {
> -             ErrorF(ConfigErrors[CONFIG_ERR_OPEN], default_config_files[i]);
> +             ErrorF(CONFIG_ERR_OPEN, default_config_files[i]);
>           }
>       }
>     }
> @@ -369,7 +366,7 @@ ReadConfigFile(const char *filename)
>     if (ret <= 0) {
>       fsfree(data);
>       (void) fclose(fp);
> -     ErrorF(ConfigErrors[CONFIG_ERR_READ], filename);
> +     ErrorF(CONFIG_ERR_READ, filename);
>       return FSBadName;
>     }
>     len = ftell(fp);
> @@ -417,7 +414,7 @@ config_parse_nameVal (
>           return c;
>       }
>     }
> -    ErrorF(ConfigErrors[CONFIG_ERR_VALUE], start);
> +    ErrorF(CONFIG_ERR_VALUE, start);
>     *c = t;
>     *ret = -1;
>     return c;
> @@ -458,7 +455,7 @@ config_parse_int(
>           skip_val(c);
>           t = *c;
>           *c = '\0';
> -         ErrorF(ConfigErrors[CONFIG_ERR_VALUE], start);
> +         ErrorF(CONFIG_ERR_VALUE, start);
>           *ret = -1;
>           *c = t;
>           return c;
> diff --git a/os/config.h b/os/config.h
> index 1a4de08..327047d 100644
> --- a/os/config.h
> +++ b/os/config.h
> @@ -51,16 +51,4 @@ in this Software without prior written authorization from 
> The Open Group.
> /* max size in bytes of config file */
> #define       CONFIG_MAX_FILESIZE     32767
> 
> -/* error codes */
> -/* these should be in the same order as the error strings in config.c */
> -#define      CONFIG_ERR_MEMORY       1
> -#define      CONFIG_ERR_OPEN         2
> -#define      CONFIG_ERR_READ         3
> -#define      CONFIG_ERR_VALUE        4
> -#define      CONFIG_ERR_UNKNOWN      5
> -#define      CONFIG_ERR_NOEQUALS     6
> -#define      CONFIG_ERR_RANGE        7
> -#define      CONFIG_ERR_SYNTAX       8
> -#define      CONFIG_ERR_NOVALUE      9
> -#define      CONFIG_ERR_EXTRAVALUE   10
> #endif                                /* _CONFIG_H_ */
> -- 
> 1.7.3.2
> 
> _______________________________________________
> xorg-devel@lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 

_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to