[janitor] tools -Wwrite-strings cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fixed warnings with gcc option "-Wwrite-strings".

Index: tools/widl/header.c
===================================================================
RCS file: /home/wine/wine/tools/widl/header.c,v
retrieving revision 1.19
diff -u -r1.19 header.c
--- tools/widl/header.c	3 Sep 2003 20:16:24 -0000	1.19
+++ tools/widl/header.c	18 Oct 2003 20:31:18 -0000
@@ -46,7 +46,7 @@
   if (delta > 0) indentation += delta;
 }
 
-int is_attr(attr_t *a, enum attr_type t)
+int is_attr(const attr_t *a, enum attr_type t)
 {
   while (a) {
     if (a->type == t) return 1;
@@ -55,7 +55,7 @@
   return 0;
 }
 
-void *get_attrp(attr_t *a, enum attr_type t)
+void *get_attrp(const attr_t *a, enum attr_type t)
 {
   while (a) {
     if (a->type == t) return a->u.pval;
@@ -73,14 +73,14 @@
   return 0;
 }
 
-int is_void(type_t *t, var_t *v)
+int is_void(const type_t *t, const var_t *v)
 {
   if (v && v->ptr_level) return 0;
   if (!t->type && !t->ref) return 1;
   return 0;
 }
 
-static void write_pident(FILE *h, var_t *v)
+static void write_pident(FILE *h, const var_t *v)
 {
   int c;
   for (c=0; c<v->ptr_level; c++) {
@@ -89,17 +89,17 @@
   if (v->name) fprintf(h, "%s", v->name);
 }
 
-void write_name(FILE *h, var_t *v)
+void write_name(FILE *h, const var_t *v)
 {
   fprintf(h, "%s", v->name);
 }
 
-char* get_name(var_t *v)
+const char* get_name(const var_t *v)
 {
   return v->name;
 }
 
-static void write_array(FILE *h, expr_t *v, int field)
+static void write_array(FILE *h, const expr_t *v, int field)
 {
   if (!v) return;
   while (NEXT_LINK(v)) v = NEXT_LINK(v);
@@ -116,7 +116,7 @@
   fprintf(h, "]");
 }
 
-static void write_field(FILE *h, var_t *v)
+static void write_field(FILE *h, const var_t *v)
 {
   if (!v) return;
   if (v->type) {
@@ -146,9 +146,9 @@
   }
 }
 
-static void write_fields(FILE *h, var_t *v)
+static void write_fields(FILE *h, const var_t *v)
 {
-  var_t *first = v;
+  const var_t *first = v;
   if (!v) return;
   while (NEXT_LINK(v)) v = NEXT_LINK(v);
   while (v) {
@@ -158,7 +158,7 @@
   }
 }
 
-static void write_enums(FILE *h, var_t *v)
+static void write_enums(FILE *h, const var_t *v)
 {
   if (!v) return;
   while (NEXT_LINK(v)) v = NEXT_LINK(v);
@@ -178,7 +178,7 @@
   fprintf(h, "\n");
 }
 
-void write_type(FILE *h, type_t *t, var_t *v, char *n)
+void write_type(FILE *h, type_t *t, const var_t *v, const char *n)
 {
   int c;
 
@@ -284,10 +284,10 @@
   }
 }
 
-void write_typedef(type_t *type, var_t *names)
+void write_typedef(type_t *type, const var_t *names)
 {
   char *tname = names->tname;
-  var_t *lname;
+  const var_t *lname;
   while (NEXT_LINK(names)) names = NEXT_LINK(names);
   lname = names;
   fprintf(header, "typedef ");
@@ -304,7 +304,7 @@
   if (get_attrp(type->attrs, ATTR_WIREMARSHAL)) {
     names = lname;
     while (names) {
-      char *name = get_name(names);
+      const char *name = get_name(names);
       fprintf(header, "unsigned long   __RPC_USER %s_UserSize     (unsigned long *, unsigned long,   %s *);\n", name, name);
       fprintf(header, "unsigned char * __RPC_USER %s_UserMarshal  (unsigned long *, unsigned char *, %s *);\n", name, name);
       fprintf(header, "unsigned char * __RPC_USER %s_UserUnmarshal(unsigned long *, unsigned char *, %s *);\n", name, name);
@@ -318,7 +318,7 @@
   fprintf(header, "\n");
 }
 
-static void do_write_expr(FILE *h, expr_t *e, int p)
+static void do_write_expr(FILE *h, const expr_t *e, int p)
 {
   switch (e->type) {
   case EXPR_VOID:
@@ -382,19 +382,19 @@
   }
 }
 
-void write_expr(FILE *h, expr_t *e)
+void write_expr(FILE *h, const expr_t *e)
 {
   do_write_expr(h, e, 0);
 }
 
-void write_constdef(var_t *v)
+void write_constdef(const var_t *v)
 {
   fprintf(header, "#define %s (", get_name(v));
   write_expr(header, v->eval);
   fprintf(header, ")\n\n");
 }
 
-void write_externdef(var_t *v)
+void write_externdef(const var_t *v)
 {
   fprintf(header, "extern const ");
   write_type(header, v->type, NULL, v->tname);
@@ -407,17 +407,17 @@
 
 /********** INTERFACES **********/
 
-int is_object(attr_t *a)
+int is_object(const attr_t *a)
 {
   return is_attr(a, ATTR_OBJECT);
 }
 
-int is_local(attr_t *a)
+int is_local(const attr_t *a)
 {
   return is_attr(a, ATTR_LOCAL);
 }
 
-var_t *is_callas(attr_t *a)
+var_t *is_callas(const attr_t *a)
 {
   return get_attrp(a, ATTR_CALLAS);
 }
@@ -469,7 +469,7 @@
   }
 }
 
-static int write_method_macro(type_t *iface, char *name)
+static int write_method_macro(type_t *iface, const char *name)
 {
   int idx;
   func_t *cur = iface->funcs;
@@ -514,7 +514,7 @@
   return idx;
 }
 
-void write_args(FILE *h, var_t *arg, char *name, int method, int do_indent)
+void write_args(FILE *h, const var_t *arg, const char *name, int method, int do_indent)
 {
   int count = 0;
   if (arg) {
@@ -563,7 +563,7 @@
   if (do_indent && h == header) indentation--;
 }
 
-static void write_cpp_method_def(type_t *iface)
+static void write_cpp_method_def(const type_t *iface)
 {
   func_t *cur = iface->funcs;
 
@@ -586,7 +586,7 @@
   }
 }
 
-static void do_write_c_method_def(type_t *iface, char *name)
+static void do_write_c_method_def(const type_t *iface, const char *name)
 {
   func_t *cur = iface->funcs;
 
@@ -612,12 +612,12 @@
   }
 }
 
-static void write_c_method_def(type_t *iface)
+static void write_c_method_def(const type_t *iface)
 {
   do_write_c_method_def(iface, iface->name);
 }
 
-static void write_method_proto(type_t *iface)
+static void write_method_proto(const type_t *iface)
 {
   func_t *cur = iface->funcs;
 
@@ -673,7 +673,7 @@
   }
 }
 
-static void write_function_proto(type_t *iface)
+static void write_function_proto(const type_t *iface)
 {
   func_t *cur = iface->funcs;
   while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
@@ -707,7 +707,7 @@
   }
 }
 
-void write_guid(type_t *iface)
+void write_guid(const type_t *iface)
 {
   UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
   if (!uuid) return;
@@ -779,7 +779,7 @@
   fprintf(header,"#endif  /* __%s_INTERFACE_DEFINED__ */\n\n", iface->name);
 }
 
-void write_rpc_interface(type_t *iface)
+void write_rpc_interface(const type_t *iface)
 {
   DWORD ver = get_attrv(iface->attrs, ATTR_VERSION);
 
Index: tools/widl/header.h
===================================================================
RCS file: /home/wine/wine/tools/widl/header.h,v
retrieving revision 1.4
diff -u -r1.4 header.h
--- tools/widl/header.h	3 Sep 2003 20:16:24 -0000	1.4
+++ tools/widl/header.h	18 Oct 2003 20:31:18 -0000
@@ -21,19 +21,19 @@
 #ifndef __WIDL_HEADER_H
 #define __WIDL_HEADER_H
 
-extern int is_void(type_t *t, var_t *v);
-extern void write_name(FILE *h, var_t *v);
-extern char* get_name(var_t *v);
-extern void write_type(FILE *h, type_t *t, var_t *v, char *n);
-extern int is_object(attr_t *a);
-extern int is_local(attr_t *a);
-extern var_t *is_callas(attr_t *a);
-extern void write_args(FILE *h, var_t *arg, char *name, int obj, int do_indent);
+extern int is_void(const type_t *t, const var_t *v);
+extern void write_name(FILE *h, const var_t *v);
+extern const char* get_name(const var_t *v);
+extern void write_type(FILE *h, type_t *t, const var_t *v, const char *n);
+extern int is_object(const attr_t *a);
+extern int is_local(const attr_t *a);
+extern var_t *is_callas(const attr_t *a);
+extern void write_args(FILE *h, const var_t *arg, const char *name, int obj, int do_indent);
 extern void write_forward(type_t *iface);
 extern void write_interface(type_t *iface);
-extern void write_typedef(type_t *type, var_t *names);
-extern void write_expr(FILE *h, expr_t *e);
-extern void write_constdef(var_t *v);
-extern void write_externdef(var_t *v);
+extern void write_typedef(type_t *type, const var_t *names);
+extern void write_expr(FILE *h, const expr_t *e);
+extern void write_constdef(const var_t *v);
+extern void write_externdef(const var_t *v);
 
 #endif
Index: tools/widl/parser.y
===================================================================
RCS file: /home/wine/wine/tools/widl/parser.y,v
retrieving revision 1.11
diff -u -r1.11 parser.y
--- tools/widl/parser.y	3 Sep 2003 20:16:24 -0000	1.11
+++ tools/widl/parser.y	18 Oct 2003 20:31:19 -0000
@@ -78,24 +78,26 @@
 static var_t *make_var(char *name);
 static func_t *make_func(var_t *def, var_t *args);
 
-static type_t *reg_type(type_t *type, char *name, int t);
+static type_t *reg_type(type_t *type, const char *name, int t);
 static type_t *reg_types(type_t *type, var_t *names, int t);
-static type_t *find_type(char *name, int t);
+static type_t *find_type(const char *name, int t);
 static type_t *find_type2(char *name, int t);
 static type_t *get_type(BYTE type, char *name, int t);
 static type_t *get_typev(BYTE type, var_t *name, int t);
 
 static var_t *reg_const(var_t *var);
-static var_t *find_const(char *name, int f);
+static var_t *find_const(const char *name, int f);
 
 #define tsENUM   1
 #define tsSTRUCT 2
 #define tsUNION  3
 
-static type_t std_bool = { "boolean" };
-static type_t std_int = { "int" };
-static type_t std_int64 = { "__int64" };
-static type_t std_uhyper = { "MIDL_uhyper" };
+#define FAKE_CHARPTR(s)	((char *)(unsigned long)(s))
+
+static type_t std_bool = { FAKE_CHARPTR("boolean") };
+static type_t std_int = { FAKE_CHARPTR("int") };
+static type_t std_int64 = { FAKE_CHARPTR("__int64") };
+static type_t std_uhyper = { FAKE_CHARPTR("MIDL_uhyper") };
 
 %}
 %union {
@@ -571,7 +573,7 @@
 	  tSWITCH '(' s_field ')'
 	  m_ident '{' cases '}'			{ var_t *u = $7;
 						  $$ = get_typev(RPC_FC_ENCAPSULATED_UNION, $2, tsUNION);
-						  if (!u) u = make_var("tagged_union");
+						  if (!u) u = make_var(FAKE_CHARPTR("tagged_union"));
 						  u->type = make_type(RPC_FC_NON_ENCAPSULATED_UNION, NULL);
 						  u->type->fields = $9;
 						  u->type->defined = TRUE;
@@ -853,7 +855,7 @@
 /***** type repository *****/
 
 struct rtype {
-  char *name;
+  const char *name;
   type_t *type;
   int t;
   struct rtype *next;
@@ -861,7 +863,7 @@
 
 struct rtype *type_hash[HASHMAX];
 
-static type_t *reg_type(type_t *type, char *name, int t)
+static type_t *reg_type(type_t *type, const char *name, int t)
 {
   struct rtype *nt;
   int hash;
@@ -908,7 +910,7 @@
   return type;
 }
 
-static type_t *find_type(char *name, int t)
+static type_t *find_type(const char *name, int t)
 {
   struct rtype *cur = type_hash[hash_ident(name)];
   while (cur && (cur->t != t || strcmp(cur->name, name)))
@@ -968,7 +970,7 @@
 /***** constant repository *****/
 
 struct rconst {
-  char *name;
+  const char *name;
   var_t *var;
   struct rconst *next;
 };
@@ -992,7 +994,7 @@
   return var;
 }
 
-static var_t *find_const(char *name, int f)
+static var_t *find_const(const char *name, int f)
 {
   struct rconst *cur = const_hash[hash_ident(name)];
   while (cur && strcmp(cur->name, name))
Index: tools/widl/proxy.c
===================================================================
RCS file: /home/wine/wine/tools/widl/proxy.c,v
retrieving revision 1.8
diff -u -r1.8 proxy.c
--- tools/widl/proxy.c	3 Sep 2003 20:16:24 -0000	1.8
+++ tools/widl/proxy.c	18 Oct 2003 20:31:19 -0000
@@ -106,7 +106,7 @@
   fprintf(proxy, "\n");
 }
 
-static void gen_stub(type_t *iface, func_t *cur, char *cas)
+static void gen_stub(type_t *iface, func_t *cur, const char *cas)
 {
   var_t *def = cur->def;
   var_t *arg;
@@ -254,7 +254,7 @@
     var_t *def = cur->def;
     if (!is_local(def->attrs)) {
       var_t *cas = is_callas(def->attrs);
-      char *cname = cas ? cas->name : NULL;
+      const char *cname = cas ? cas->name : NULL;
       int idx = cur->idx;
       if (cname) {
         func_t *m = iface->funcs;
Index: tools/widl/widltypes.h
===================================================================
RCS file: /home/wine/wine/tools/widl/widltypes.h,v
retrieving revision 1.10
diff -u -r1.10 widltypes.h
--- tools/widl/widltypes.h	5 Sep 2003 23:15:40 -0000	1.10
+++ tools/widl/widltypes.h	18 Oct 2003 20:31:19 -0000
@@ -112,7 +112,7 @@
   expr_t *ref;
   union {
     long lval;
-    char *sval;
+    const char *sval;
     expr_t *ext;
     typeref_t *tref;
   } u;
Index: tools/winedump/msmangle.c
===================================================================
RCS file: /home/wine/wine/tools/winedump/msmangle.c,v
retrieving revision 1.11
diff -u -r1.11 msmangle.c
--- tools/winedump/msmangle.c	22 Jul 2003 00:56:31 -0000	1.11
+++ tools/winedump/msmangle.c	18 Oct 2003 20:31:21 -0000
@@ -69,7 +69,8 @@
   int is_static = 0, is_const = 0;
   char *function_name = NULL;
   char *class_name = NULL;
-  char *name, *const_status;
+  char *name;
+  const char *const_status;
   static unsigned int hash = 0; /* In case of overloaded functions */
   unsigned int data_flags = 0;
 
@@ -673,7 +674,7 @@
  */
 static char *get_type_string (const char c, const int constraints)
 {
-  char *type_string;
+  const char *type_string;
 
   if (constraints & CT_EXTENDED)
   {
Index: tools/winedump/pe.c
===================================================================
RCS file: /home/wine/wine/tools/winedump/pe.c,v
retrieving revision 1.27
diff -u -r1.27 pe.c
--- tools/winedump/pe.c	10 Sep 2003 04:00:20 -0000	1.27
+++ tools/winedump/pe.c	18 Oct 2003 20:31:22 -0000
@@ -151,7 +151,7 @@
 
 static	void	dump_pe_header(void)
 {
-    char			*str;
+    const char			*str;
     IMAGE_FILE_HEADER		*fileHeader;
     IMAGE_OPTIONAL_HEADER	*optionalHeader;
     unsigned			i;
@@ -1142,7 +1142,7 @@
     DWORD*			pName;
     DWORD*			pFunc;
     WORD*			pOrdl;
-    char*			ptr;
+    const char*			ptr;
     DWORD*			map;
 
     if (!exportDir) return;
Index: tools/winedump/winedump.h
===================================================================
RCS file: /home/wine/wine/tools/winedump/winedump.h,v
retrieving revision 1.7
diff -u -r1.7 winedump.h
--- tools/winedump/winedump.h	2 Oct 2002 18:50:09 -0000	1.7
+++ tools/winedump/winedump.h	18 Oct 2003 20:31:23 -0000
@@ -129,7 +129,7 @@
   const char *directory;   /* -I */
   const char *forward_dll; /* -f */
   const char *dll_name;    /* -o */
-  char *uc_dll_name;       /* -o */
+  const char *uc_dll_name; /* -o */
 
   /* Option arguments: dump mode */
   const char *dumpsect;    /* -j */
Index: tools/wmc/lang.h
===================================================================
RCS file: /home/wine/wine/tools/wmc/lang.h,v
retrieving revision 1.2
diff -u -r1.2 lang.h
--- tools/wmc/lang.h	10 Mar 2002 00:24:24 -0000	1.2
+++ tools/wmc/lang.h	18 Oct 2003 20:31:23 -0000
@@ -27,8 +27,8 @@
 	unsigned	id;
 	unsigned	doscp;
 	unsigned	wincp;
-	char		*name;
-	char		*country;
+	const char	*name;
+	const char	*country;
 } language_t;
 
 void show_languages(void);
Index: tools/wmc/write.c
===================================================================
RCS file: /home/wine/wine/tools/wmc/write.c,v
retrieving revision 1.8
diff -u -r1.8 write.c
--- tools/wmc/write.c	2 Oct 2003 04:29:30 -0000	1.8
+++ tools/wmc/write.c	18 Oct 2003 20:31:23 -0000
@@ -466,7 +466,7 @@
 			{
 				char *cptr;
 				int l = blk->msgs[j]->len;
-				char *comma = j == blk->nmsg-1  && i == lbp->nblk-1 ? "" : ",";
+				const char *comma = j == blk->nmsg-1  && i == lbp->nblk-1 ? "" : ",";
 				cptr = make_string(blk->msgs[j]->msg, l, unicodeout ? 0 : blk->msgs[j]->cp);
 				fprintf(fp, "\n /* Msg 0x%08x */ 0x%04x, 0x000%c,\n",
 					blk->idlo + j,

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux