[PATCH 02/44] hw/xfree86: Lots of constant string support
Keith Packard
keithp at keithp.com
Wed Dec 11 12:23:34 PST 2013
Make lots of string pointers 'const char' so that we can use constant
strings with them without eliciting warnings.
Signed-off-by: Keith Packard <keithp at keithp.com>
---
hw/xfree86/common/dgaproc.h | 2 +-
hw/xfree86/common/xf86.h | 2 +-
hw/xfree86/common/xf86Configure.c | 6 ++-
hw/xfree86/common/xf86Opt.h | 2 +-
hw/xfree86/common/xf86Optionstr.h | 6 +--
hw/xfree86/common/xf86Privstr.h | 2 +-
hw/xfree86/common/xf86Xinput.h | 4 +-
hw/xfree86/common/xf86sbusBus.h | 10 ++--
hw/xfree86/common/xf86str.h | 42 ++++++++---------
hw/xfree86/common/xf86xv.h | 6 +--
hw/xfree86/common/xf86xvmc.h | 2 +-
hw/xfree86/parser/Configint.h | 2 +-
hw/xfree86/parser/Files.c | 3 +-
hw/xfree86/parser/Flags.c | 14 +++---
hw/xfree86/parser/configProcs.h | 2 +-
hw/xfree86/parser/scan.c | 15 +++---
hw/xfree86/parser/xf86Parser.h | 96 +++++++++++++++++++--------------------
17 files changed, 109 insertions(+), 107 deletions(-)
diff --git a/hw/xfree86/common/dgaproc.h b/hw/xfree86/common/dgaproc.h
index e824d30..87e923f 100644
--- a/hw/xfree86/common/dgaproc.h
+++ b/hw/xfree86/common/dgaproc.h
@@ -24,7 +24,7 @@
typedef struct {
int num; /* A unique identifier for the mode (num > 0) */
- char *name; /* name of mode given in the XF86Config */
+ const char *name; /* name of mode given in the XF86Config */
int VSync_num;
int VSync_den;
int flags; /* DGA_CONCURRENT_ACCESS, etc... */
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index eada01c..9fc0c5b 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -349,7 +349,7 @@ xf86SetBackingStore(ScreenPtr pScreen);
extern _X_EXPORT void
xf86SetSilkenMouse(ScreenPtr pScreen);
extern _X_EXPORT pointer
-xf86FindXvOptions(ScrnInfoPtr pScrn, int adapt_index, char *port_name,
+xf86FindXvOptions(ScrnInfoPtr pScrn, int adapt_index, const char *port_name,
char **adaptor_name, pointer *adaptor_options);
extern _X_EXPORT void
xf86GetOS(const char **name, int *major, int *minor, int *teeny);
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 91e8df9..5bf1f14 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -81,6 +81,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData,
int chipset)
{
int ret, i, j;
+ char *lower_driver;
if (!xf86DoConfigure || !xf86DoConfigurePass1)
return NULL;
@@ -117,8 +118,9 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData,
DevToConfig[i].iDriver = CurrentDriver;
/* Fill in what we know, converting the driver name to lower case */
- DevToConfig[i].GDev.driver = xnfalloc(strlen(driver) + 1);
- for (j = 0; (DevToConfig[i].GDev.driver[j] = tolower(driver[j])); j++);
+ lower_driver = xnfalloc(strlen(driver) + 1);
+ for (j = 0; (lower_driver[j] = tolower(driver[j])); j++);
+ DevToConfig[i].GDev.driver = lower_driver;
switch (bus) {
#ifdef XSERVER_LIBPCIACCESS
diff --git a/hw/xfree86/common/xf86Opt.h b/hw/xfree86/common/xf86Opt.h
index c3ba2d7..f99a924 100644
--- a/hw/xfree86/common/xf86Opt.h
+++ b/hw/xfree86/common/xf86Opt.h
@@ -39,7 +39,7 @@ typedef struct {
typedef union {
unsigned long num;
- char *str;
+ const char *str;
double realnum;
Bool bool;
OptFrequency freq;
diff --git a/hw/xfree86/common/xf86Optionstr.h b/hw/xfree86/common/xf86Optionstr.h
index c38499c..4ef917d 100644
--- a/hw/xfree86/common/xf86Optionstr.h
+++ b/hw/xfree86/common/xf86Optionstr.h
@@ -31,10 +31,10 @@
*/
typedef struct _XF86OptionRec {
GenericListRec list;
- char *opt_name;
- char *opt_val;
+ const char *opt_name;
+ const char *opt_val;
int opt_used;
- char *opt_comment;
+ const char *opt_comment;
} XF86OptionRec;
typedef struct _InputOption *XF86OptionPtr;
diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h
index e20be03..ddcb3ca 100644
--- a/hw/xfree86/common/xf86Privstr.h
+++ b/hw/xfree86/common/xf86Privstr.h
@@ -136,7 +136,7 @@ typedef struct {
/* Information for root window properties. */
typedef struct _RootWinProp {
struct _RootWinProp *next;
- char *name;
+ const char *name;
Atom type;
short format;
long size;
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index 35c38a5..b95fbe5 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -82,8 +82,8 @@ typedef struct _InputDriverRec {
typedef struct _InputInfoRec {
struct _InputInfoRec *next;
- char *name;
- char *driver;
+ const char *name;
+ const char *driver;
int flags;
diff --git a/hw/xfree86/common/xf86sbusBus.h b/hw/xfree86/common/xf86sbusBus.h
index a4d9c6c..5ebdf25 100644
--- a/hw/xfree86/common/xf86sbusBus.h
+++ b/hw/xfree86/common/xf86sbusBus.h
@@ -52,16 +52,16 @@ typedef struct sbus_device {
int fd;
int width, height;
sbusPromNode node;
- char *descr;
- char *device;
+ const char *descr;
+ const char *device;
} sbusDevice, *sbusDevicePtr;
struct sbus_devtable {
int devId;
int fbType;
- char *promName;
- char *driverName;
- char *descr;
+ const char *promName;
+ const char *driverName;
+ const char *descr;
};
extern _X_EXPORT void xf86SbusProbe(void);
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index 0244fd4..d90d1ad 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -145,7 +145,7 @@ typedef enum {
typedef struct _DisplayModeRec {
struct _DisplayModeRec *prev;
struct _DisplayModeRec *next;
- char *name; /* identifier for the mode */
+ const char *name; /* identifier for the mode */
ModeStatus status;
int type;
@@ -212,9 +212,9 @@ typedef struct {
#define GAMMA_ZERO (GAMMA_MIN / 100.0)
typedef struct {
- char *id;
- char *vendor;
- char *model;
+ const char *id;
+ const char *vendor;
+ const char *model;
int nHsync;
range hsync[MAX_HSYNC];
int nVrefresh;
@@ -386,19 +386,19 @@ typedef enum {
} DacSpeedIndex;
typedef struct {
- char *identifier;
- char *vendor;
- char *board;
- char *chipset;
- char *ramdac;
- char *driver;
+ const char *identifier;
+ const char *vendor;
+ const char *board;
+ const char *chipset;
+ const char *ramdac;
+ const char *driver;
struct _confscreenrec *myScreenSection;
Bool claimed;
int dacSpeeds[MAXDACSPEEDS];
int numclocks;
int clock[MAXCLOCKS];
- char *clockchip;
- char *busID;
+ const char *clockchip;
+ const char *busID;
Bool active;
Bool inUse;
int videoRam;
@@ -429,19 +429,19 @@ typedef struct {
} DispRec, *DispPtr;
typedef struct _confxvportrec {
- char *identifier;
+ const char *identifier;
pointer options;
} confXvPortRec, *confXvPortPtr;
typedef struct _confxvadaptrec {
- char *identifier;
+ const char *identifier;
int numports;
confXvPortPtr ports;
pointer options;
} confXvAdaptorRec, *confXvAdaptorPtr;
typedef struct _confscreenrec {
- char *id;
+ const char *id;
int screennum;
int defaultdepth;
int defaultbpp;
@@ -467,25 +467,25 @@ typedef enum {
typedef struct _screenlayoutrec {
confScreenPtr screen;
- char *topname;
+ const char *topname;
confScreenPtr top;
- char *bottomname;
+ const char *bottomname;
confScreenPtr bottom;
- char *leftname;
+ const char *leftname;
confScreenPtr left;
- char *rightname;
+ const char *rightname;
confScreenPtr right;
PositionType where;
int x;
int y;
- char *refname;
+ const char *refname;
confScreenPtr refscreen;
} screenLayoutRec, *screenLayoutPtr;
typedef struct _InputInfoRec InputInfoRec;
typedef struct _serverlayoutrec {
- char *id;
+ const char *id;
screenLayoutPtr screens;
GDevPtr inactives;
InputInfoRec **inputs; /* NULL terminated */
diff --git a/hw/xfree86/common/xf86xv.h b/hw/xfree86/common/xf86xv.h
index 091efca..f393369 100644
--- a/hw/xfree86/common/xf86xv.h
+++ b/hw/xfree86/common/xf86xv.h
@@ -137,7 +137,7 @@ typedef enum {
typedef struct {
int id;
- char *name;
+ const char *name;
unsigned short width, height;
XvRationalRec rate;
} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
@@ -151,13 +151,13 @@ typedef struct {
int flags;
int min_value;
int max_value;
- char *name;
+ const char *name;
} XF86AttributeRec, *XF86AttributePtr;
typedef struct {
unsigned int type;
int flags;
- char *name;
+ const char *name;
int nEncodings;
XF86VideoEncodingPtr pEncodings;
int nFormats;
diff --git a/hw/xfree86/common/xf86xvmc.h b/hw/xfree86/common/xf86xvmc.h
index 2478fe3..aaa4e65 100644
--- a/hw/xfree86/common/xf86xvmc.h
+++ b/hw/xfree86/common/xf86xvmc.h
@@ -109,7 +109,7 @@ typedef void (*xf86XvMCDestroySubpictureProcPtr) (ScrnInfoPtr pScrn,
XvMCSubpicturePtr subpicture);
typedef struct {
- char *name;
+ const char *name;
int num_surfaces;
XF86MCSurfaceInfoPtr *surfaces;
int num_subpictures;
diff --git a/hw/xfree86/parser/Configint.h b/hw/xfree86/parser/Configint.h
index 81cc1fc..62e5142 100644
--- a/hw/xfree86/parser/Configint.h
+++ b/hw/xfree86/parser/Configint.h
@@ -90,7 +90,7 @@ typedef struct {
#include "configProcs.h"
#include <stdlib.h>
-#define TestFree(a) if (a) { free (a); a = NULL; }
+#define TestFree(a) if (a) { free ((void *) a); a = NULL; }
#define parsePrologue(typeptr,typerec) typeptr ptr; \
if( (ptr=calloc(1,sizeof(typerec))) == NULL ) { return NULL; }
diff --git a/hw/xfree86/parser/Files.c b/hw/xfree86/parser/Files.c
index 0d3e47a..a6e18dd 100644
--- a/hw/xfree86/parser/Files.c
+++ b/hw/xfree86/parser/Files.c
@@ -97,8 +97,7 @@ xf86parseFilesSection(void)
j = FALSE;
str = val.str;
if (ptr->file_fontpath == NULL) {
- ptr->file_fontpath = malloc(1);
- ptr->file_fontpath[0] = '\0';
+ ptr->file_fontpath = calloc(1, 1);
i = strlen(str) + 1;
}
else {
diff --git a/hw/xfree86/parser/Flags.c b/hw/xfree86/parser/Flags.c
index 2461476..326c6b7 100644
--- a/hw/xfree86/parser/Flags.c
+++ b/hw/xfree86/parser/Flags.c
@@ -189,7 +189,7 @@ xf86printServerFlagsSection(FILE * f, XF86ConfFlagsPtr flags)
}
static XF86OptionPtr
-addNewOption2(XF86OptionPtr head, char *name, char *val, int used)
+addNewOption2(XF86OptionPtr head, char *name, char *_val, int used)
{
XF86OptionPtr new, old = NULL;
@@ -202,7 +202,7 @@ addNewOption2(XF86OptionPtr head, char *name, char *val, int used)
else
new = calloc(1, sizeof(*new));
new->opt_name = name;
- new->opt_val = val;
+ new->opt_val = _val;
new->opt_used = used;
if (old)
@@ -211,9 +211,9 @@ addNewOption2(XF86OptionPtr head, char *name, char *val, int used)
}
XF86OptionPtr
-xf86addNewOption(XF86OptionPtr head, char *name, char *val)
+xf86addNewOption(XF86OptionPtr head, char *name, char *_val)
{
- return addNewOption2(head, name, val, 0);
+ return addNewOption2(head, name, _val, 0);
}
void
@@ -230,11 +230,11 @@ XF86OptionPtr
xf86optionListDup(XF86OptionPtr opt)
{
XF86OptionPtr newopt = NULL;
- char *val;
+ char *_val;
while (opt) {
- val = opt->opt_val ? strdup(opt->opt_val) : NULL;
- newopt = xf86addNewOption(newopt, strdup(opt->opt_name), val);
+ _val = opt->opt_val ? strdup(opt->opt_val) : NULL;
+ newopt = xf86addNewOption(newopt, strdup(opt->opt_name), _val);
newopt->opt_used = opt->opt_used;
if (opt->opt_comment)
newopt->opt_comment = strdup(opt->opt_comment);
diff --git a/hw/xfree86/parser/configProcs.h b/hw/xfree86/parser/configProcs.h
index 1250f39..4576ee1 100644
--- a/hw/xfree86/parser/configProcs.h
+++ b/hw/xfree86/parser/configProcs.h
@@ -141,7 +141,7 @@ xf86freeExtensions(XF86ConfExtensionsPtr ptr);
#include <xorg-config.h>
#endif
-#ifndef IN_XSERVER
+#ifndef HAVE_XORG_CONFIG_H
/* Externally provided functions */
void
ErrorF(const char *f, ...);
diff --git a/hw/xfree86/parser/scan.c b/hw/xfree86/parser/scan.c
index f852b83..55a8442 100644
--- a/hw/xfree86/parser/scan.c
+++ b/hw/xfree86/parser/scan.c
@@ -820,7 +820,7 @@ static char *
OpenConfigDir(const char *path, const char *cmdline, const char *projroot,
const char *confname)
{
- char *dirpath, *pathcopy;
+ char *dirpath = NULL, *pathcopy;
const char *template;
Bool found = FALSE;
int cmdlineUsed = 0;
@@ -1078,9 +1078,10 @@ xf86nameCompare(const char *s1, const char *s2)
}
char *
-xf86addComment(char *cur, char *add)
+xf86addComment(char *cur, const char *add)
{
char *str;
+ const char *cstr;
int len, curlen, iscomment, hasnewline = 0, insnewline, endnewline;
if (add == NULL || add[0] == '\0')
@@ -1095,14 +1096,14 @@ xf86addComment(char *cur, char *add)
else
curlen = 0;
- str = add;
+ cstr = add;
iscomment = 0;
- while (*str) {
- if (*str != ' ' && *str != '\t')
+ while (*cstr) {
+ if (*cstr != ' ' && *cstr != '\t')
break;
- ++str;
+ ++cstr;
}
- iscomment = (*str == '#');
+ iscomment = (*cstr == '#');
len = strlen(add);
endnewline = add[len - 1] == '\n';
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index e7210e8..1f66329 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -85,7 +85,7 @@ typedef struct {
typedef struct {
GenericListRec list;
int load_type;
- char *load_name;
+ const char *load_name;
XF86OptionPtr load_opt;
char *load_comment;
int ignore;
@@ -116,7 +116,7 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *ml_identifier;
+ const char *ml_identifier;
int ml_clock;
int ml_hdisplay;
int ml_hsyncstart;
@@ -134,21 +134,21 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *vp_identifier;
+ const char *vp_identifier;
XF86OptionPtr vp_option_lst;
char *vp_comment;
} XF86ConfVideoPortRec, *XF86ConfVideoPortPtr;
typedef struct {
GenericListRec list;
- char *va_identifier;
- char *va_vendor;
- char *va_board;
- char *va_busid;
- char *va_driver;
+ const char *va_identifier;
+ const char *va_vendor;
+ const char *va_board;
+ const char *va_busid;
+ const char *va_driver;
XF86OptionPtr va_option_lst;
XF86ConfVideoPortPtr va_port_lst;
- char *va_fwdref;
+ const char *va_fwdref;
char *va_comment;
} XF86ConfVideoAdaptorRec, *XF86ConfVideoAdaptorPtr;
@@ -165,22 +165,22 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *modes_identifier;
+ const char *modes_identifier;
XF86ConfModeLinePtr mon_modeline_lst;
char *modes_comment;
} XF86ConfModesRec, *XF86ConfModesPtr;
typedef struct {
GenericListRec list;
- char *ml_modes_str;
+ const char *ml_modes_str;
XF86ConfModesPtr ml_modes;
} XF86ConfModesLinkRec, *XF86ConfModesLinkPtr;
typedef struct {
GenericListRec list;
- char *mon_identifier;
- char *mon_vendor;
- char *mon_modelname;
+ const char *mon_identifier;
+ const char *mon_vendor;
+ const char *mon_modelname;
int mon_width; /* in mm */
int mon_height; /* in mm */
XF86ConfModeLinePtr mon_modeline_lst;
@@ -201,21 +201,21 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *dev_identifier;
- char *dev_vendor;
- char *dev_board;
- char *dev_chipset;
- char *dev_busid;
- char *dev_card;
- char *dev_driver;
- char *dev_ramdac;
+ const char *dev_identifier;
+ const char *dev_vendor;
+ const char *dev_board;
+ const char *dev_chipset;
+ const char *dev_busid;
+ const char *dev_card;
+ const char *dev_driver;
+ const char *dev_ramdac;
int dev_dacSpeeds[CONF_MAXDACSPEEDS];
int dev_videoram;
int dev_textclockfreq;
unsigned long dev_bios_base;
unsigned long dev_mem_base;
unsigned long dev_io_base;
- char *dev_clockchip;
+ const char *dev_clockchip;
int dev_clocks;
int dev_clock[CONF_MAXCLOCKS];
int dev_chipid;
@@ -228,7 +228,7 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *mode_name;
+ const char *mode_name;
} XF86ModeRec, *XF86ModePtr;
typedef struct {
@@ -239,7 +239,7 @@ typedef struct {
int disp_virtualY;
int disp_depth;
int disp_bpp;
- char *disp_visual;
+ const char *disp_visual;
parser_rgb disp_weight;
parser_rgb disp_black;
parser_rgb disp_white;
@@ -255,20 +255,20 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *al_adaptor_str;
+ const char *al_adaptor_str;
XF86ConfVideoAdaptorPtr al_adaptor;
} XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
typedef struct {
GenericListRec list;
- char *scrn_identifier;
- char *scrn_obso_driver;
+ const char *scrn_identifier;
+ const char *scrn_obso_driver;
int scrn_defaultdepth;
int scrn_defaultbpp;
int scrn_defaultfbbpp;
- char *scrn_monitor_str;
+ const char *scrn_monitor_str;
XF86ConfMonitorPtr scrn_monitor;
- char *scrn_device_str;
+ const char *scrn_device_str;
XF86ConfDevicePtr scrn_device;
XF86ConfAdaptorLinkPtr scrn_adaptor_lst;
XF86ConfDisplayPtr scrn_display_lst;
@@ -279,8 +279,8 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *inp_identifier;
- char *inp_driver;
+ const char *inp_identifier;
+ const char *inp_driver;
XF86OptionPtr inp_option_lst;
char *inp_comment;
} XF86ConfInputRec, *XF86ConfInputPtr;
@@ -288,7 +288,7 @@ typedef struct {
typedef struct {
GenericListRec list;
XF86ConfInputPtr iref_inputdev;
- char *iref_inputdev_str;
+ const char *iref_inputdev_str;
XF86OptionPtr iref_option_lst;
} XF86ConfInputrefRec, *XF86ConfInputrefPtr;
@@ -304,8 +304,8 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *identifier;
- char *driver;
+ const char *identifier;
+ const char *driver;
struct xorg_list match_product;
struct xorg_list match_vendor;
struct xorg_list match_device;
@@ -338,30 +338,30 @@ typedef struct {
GenericListRec list;
int adj_scrnum;
XF86ConfScreenPtr adj_screen;
- char *adj_screen_str;
+ const char *adj_screen_str;
XF86ConfScreenPtr adj_top;
- char *adj_top_str;
+ const char *adj_top_str;
XF86ConfScreenPtr adj_bottom;
- char *adj_bottom_str;
+ const char *adj_bottom_str;
XF86ConfScreenPtr adj_left;
- char *adj_left_str;
+ const char *adj_left_str;
XF86ConfScreenPtr adj_right;
- char *adj_right_str;
+ const char *adj_right_str;
int adj_where;
int adj_x;
int adj_y;
- char *adj_refscreen;
+ const char *adj_refscreen;
} XF86ConfAdjacencyRec, *XF86ConfAdjacencyPtr;
typedef struct {
GenericListRec list;
- char *inactive_device_str;
+ const char *inactive_device_str;
XF86ConfDevicePtr inactive_device;
} XF86ConfInactiveRec, *XF86ConfInactivePtr;
typedef struct {
GenericListRec list;
- char *lay_identifier;
+ const char *lay_identifier;
XF86ConfAdjacencyPtr lay_adjacency_lst;
XF86ConfInactivePtr lay_inactive_lst;
XF86ConfInputrefPtr lay_input_lst;
@@ -371,22 +371,22 @@ typedef struct {
typedef struct {
GenericListRec list;
- char *vs_name;
- char *vs_identifier;
+ const char *vs_name;
+ const char *vs_identifier;
XF86OptionPtr vs_option_lst;
char *vs_comment;
} XF86ConfVendSubRec, *XF86ConfVendSubPtr;
typedef struct {
GenericListRec list;
- char *vnd_identifier;
+ const char *vnd_identifier;
XF86OptionPtr vnd_option_lst;
XF86ConfVendSubPtr vnd_sub_lst;
char *vnd_comment;
} XF86ConfVendorRec, *XF86ConfVendorPtr;
typedef struct {
- char *dri_group_name;
+ const char *dri_group_name;
int dri_group;
int dri_mode;
char *dri_comment;
@@ -462,7 +462,7 @@ extern _X_EXPORT int xf86itemNotSublist(GenericListPtr list_1,
extern _X_EXPORT int xf86pathIsAbsolute(const char *path);
extern _X_EXPORT int xf86pathIsSafe(const char *path);
-extern _X_EXPORT char *xf86addComment(char *cur, char *add);
+extern _X_EXPORT char *xf86addComment(char *cur, const char *add);
extern _X_EXPORT Bool xf86getBoolValue(Bool *val, const char *str);
#endif /* _xf86Parser_h_ */
--
1.8.4.4
More information about the xorg-devel
mailing list