xserver: Branch 'master' - 11 commits

Keith Packard keithp at kemper.freedesktop.org
Fri Jun 11 14:12:49 PDT 2010


 config/config.c                   |    4 ++--
 config/dbus.c                     |    8 ++++----
 config/hal.c                      |   14 +++++++-------
 config/udev.c                     |    6 +++---
 dix/dixfonts.c                    |    2 +-
 exa/exa_glyphs.c                  |   12 ++++--------
 glx/glxcmds.c                     |    2 +-
 glx/glxscreens.c                  |    6 +++---
 hw/dmx/input/dmxinputinit.c       |    4 ++--
 hw/dmx/input/usb-keyboard.c       |    2 +-
 hw/kdrive/ephyr/ephyrhostvideo.c  |    6 ++----
 hw/kdrive/ephyr/hostx.c           |   25 ++++++++-----------------
 hw/kdrive/src/kinput.c            |   12 ++++++------
 hw/xfree86/common/xf86Configure.c |   20 ++++++++++----------
 hw/xfree86/common/xf86Option.c    |    2 +-
 hw/xfree86/loader/loadmod.c       |    6 +++---
 hw/xfree86/modes/xf86Cursors.c    |    7 ++-----
 hw/xfree86/os-support/bus/Sbus.c  |    6 ++----
 hw/xquartz/GL/indirect.c          |   12 ++++++------
 hw/xwin/InitOutput.c              |   13 +++++--------
 hw/xwin/glx/indirect.c            |    6 +++---
 hw/xwin/winconfig.c               |    4 ++--
 record/record.c                   |    4 ++--
 xkb/XKBGAlloc.c                   |   18 ++++++------------
 xkb/XKBMAlloc.c                   |   18 ++++++------------
 xkb/ddxList.c                     |    5 +----
 xkb/ddxLoad.c                     |    7 ++++++-
 xkb/xkb.c                         |   21 ++++++++++++---------
 xkb/xkbInit.c                     |    6 ++----
 xkb/xkbUtils.c                    |   12 ++++++------
 30 files changed, 119 insertions(+), 151 deletions(-)

New commits:
commit a41d6e9bffbe56cfa1c3b84388a3d9f5a982f1a9
Merge: 7e8f100... f4190fe...
Author: Keith Packard <keithp at keithp.com>
Date:   Fri Jun 11 10:08:13 2010 -0700

    Merge remote branch 'dottedmag/for-keithp'

commit f4190feb25ecc3d8278decc8bf28a5ef0e568942
Author: Matt Turner <mattst88 at gmail.com>
Date:   Thu Jun 10 04:08:54 2010 +0700

    Remove more superfluous if(p) checks around free(p)
    
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>
    Signed-off-by: Matt Turner <mattst88 at gmail.com>
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>

diff --git a/exa/exa_glyphs.c b/exa/exa_glyphs.c
index b09db46..5c46ec9 100644
--- a/exa/exa_glyphs.c
+++ b/exa/exa_glyphs.c
@@ -127,15 +127,11 @@ exaUnrealizeGlyphCaches(ScreenPtr    pScreen,
 	    cache->picture = NULL;
 	}
 
-	if (cache->hashEntries) {
-	    free(cache->hashEntries);
-	    cache->hashEntries = NULL;
-	}
+	free(cache->hashEntries);
+	cache->hashEntries = NULL;
 	
-	if (cache->glyphs) {
-	    free(cache->glyphs);
-	    cache->glyphs = NULL;
-	}
+	free(cache->glyphs);
+	cache->glyphs = NULL;
 	cache->glyphCount = 0;
     }
 }
diff --git a/hw/kdrive/ephyr/ephyrhostvideo.c b/hw/kdrive/ephyr/ephyrhostvideo.c
index 38927b0..9dde768 100644
--- a/hw/kdrive/ephyr/ephyrhostvideo.c
+++ b/hw/kdrive/ephyr/ephyrhostvideo.c
@@ -831,10 +831,8 @@ out:
         XFreeGC (dpy, gc) ;
         gc = NULL ;
     }
-    if (rects) {
-        free (rects) ;
-        rects = NULL ;
-    }
+    free(rects);
+    rects = NULL;
     EPHYR_LOG ("leave\n") ;
     return is_ok ;
 }
diff --git a/hw/kdrive/ephyr/hostx.c b/hw/kdrive/ephyr/hostx.c
index 38ee06d..2ebeca9 100644
--- a/hw/kdrive/ephyr/hostx.c
+++ b/hw/kdrive/ephyr/hostx.c
@@ -669,11 +669,8 @@ hostx_screen_init (EphyrScreenInfo screen,
 	}
       else
 	{
-	  if (host_screen->ximg->data) 
-	    {
-	      free(host_screen->ximg->data);
-	      host_screen->ximg->data = NULL;
-	    } 
+	  free(host_screen->ximg->data);
+	  host_screen->ximg->data = NULL;
 
 	  XDestroyImage(host_screen->ximg);
 	}
@@ -1160,10 +1157,8 @@ out:
         XFree (visuals) ;
         visuals = NULL;
     }
-    if (host_visuals) {
-        free (host_visuals) ;
-        host_visuals = NULL;
-    }
+    free(host_visuals);
+    host_visuals = NULL;
     EPHYR_LOG ("leave\n") ;
     return is_ok ;
 
@@ -1292,10 +1287,8 @@ hostx_set_window_bounding_rectangles (int a_window,
                              rects, a_num_rects, ShapeSet, YXBanded) ;
     is_ok = TRUE ;
 
-    if (rects) {
-        free (rects) ;
-        rects = NULL ;
-    }
+    free(rects);
+    rects = NULL;
     EPHYR_LOG ("leave\n") ;
     return is_ok;
 }
@@ -1329,10 +1322,8 @@ hostx_set_window_clipping_rectangles (int a_window,
                              rects, a_num_rects, ShapeSet, YXBanded) ;
     is_ok = TRUE ;
 
-    if (rects) {
-        free (rects) ;
-        rects = NULL ;
-    }
+    free(rects);
+    rects = NULL;
     EPHYR_LOG ("leave\n") ;
     return is_ok;
 }
diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c
index 5842a61..038f1c8 100644
--- a/hw/xfree86/modes/xf86Cursors.c
+++ b/hw/xfree86/modes/xf86Cursors.c
@@ -659,11 +659,8 @@ xf86_cursors_fini (ScreenPtr screen)
 	xf86DestroyCursorInfoRec (xf86_config->cursor_info);
 	xf86_config->cursor_info = NULL;
     }
-    if (xf86_config->cursor_image)
-    {
-	free(xf86_config->cursor_image);
-	xf86_config->cursor_image = NULL;
-    }
+    free(xf86_config->cursor_image);
+    xf86_config->cursor_image = NULL;
     if (xf86_config->cursor)
     {
 	FreeCursor (xf86_config->cursor, None);
diff --git a/hw/xfree86/os-support/bus/Sbus.c b/hw/xfree86/os-support/bus/Sbus.c
index 9ccc289..7829d80 100644
--- a/hw/xfree86/os-support/bus/Sbus.c
+++ b/hw/xfree86/os-support/bus/Sbus.c
@@ -191,10 +191,8 @@ sparcPromClose(void)
 	close(promFd);
 	promFd = -1;
     }
-    if (promOpio) {
-	free(promOpio);
-	promOpio = NULL;
-    }
+    free(promOpio);
+    promOpio = NULL;
     promOpenCount = 0;
 }
 
diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 1b97606..73cc263 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -275,11 +275,8 @@ ddxGiveUp (void)
     }
   
   /* Free concatenated command line */
-  if (g_pszCommandLine)
-    {
-      free (g_pszCommandLine);
-      g_pszCommandLine = NULL;
-    }
+  free(g_pszCommandLine);
+  g_pszCommandLine = NULL;
 
   /* Remove our keyboard hook if it is installed */
   winRemoveKeyboardHookLL ();
diff --git a/xkb/XKBGAlloc.c b/xkb/XKBGAlloc.c
index 796931c..d1adea3 100644
--- a/xkb/XKBGAlloc.c
+++ b/xkb/XKBGAlloc.c
@@ -114,10 +114,8 @@ register char *ptr;
     }
     if (freeAll) {
 	(*num_inout)= (*sz_inout)= 0;
-	if (*elems) {
-	    free(*elems);
-	    *elems= NULL;
-	}
+	free(*elems);
+	*elems = NULL;
     }
     else if (first+count>=(*num_inout))
 	*num_inout= first;
@@ -137,14 +135,10 @@ _XkbClearProperty(char *prop_in)
 {
 XkbPropertyPtr	prop= (XkbPropertyPtr)prop_in;
 
-    if (prop->name) {
-	free(prop->name);
-	prop->name= NULL;
-    }
-    if (prop->value) {
-	free(prop->value);
-	prop->value= NULL;
-    }
+    free(prop->name);
+    prop->name = NULL;
+    free(prop->value);
+    prop->value = NULL;
     return;
 }
 
diff --git a/xkb/XKBMAlloc.c b/xkb/XKBMAlloc.c
index 197523f..6b186c1 100644
--- a/xkb/XKBMAlloc.c
+++ b/xkb/XKBMAlloc.c
@@ -221,18 +221,12 @@ XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
 {
     if ((!from)||(!into))
 	return BadMatch;
-    if (into->map) {
-	free(into->map);
-	into->map= NULL;
-    }
-    if (into->preserve) {
-	free(into->preserve);
-	into->preserve= NULL;
-    }
-    if (into->level_names) {
-	free(into->level_names);
-	into->level_names= NULL;
-    }
+    free(into->map);
+    into->map = NULL;
+    free(into->preserve);
+    into->preserve = NULL;
+    free(into->level_names);
+    into->level_names = NULL;
     *into= *from;
     if ((from->map)&&(into->map_count>0)) {
 	into->map= calloc(into->map_count, sizeof(XkbKTMapEntryRec));
diff --git a/xkb/ddxList.c b/xkb/ddxList.c
index eee3887..2256424 100644
--- a/xkb/ddxList.c
+++ b/xkb/ddxList.c
@@ -208,10 +208,7 @@ char	tmpname[PATH_MAX];
 	return BadImplementation;
     }
     list->nFound[what]= 0;
-    if (buf) {
-        free(buf);
-        buf = NULL;
-    }
+    free(buf);
     buf = malloc(PATH_MAX * sizeof(char));
     if (!buf)
         return BadAlloc;
diff --git a/xkb/xkb.c b/xkb/xkb.c
index cbb46c6..bd73e9a 100644
--- a/xkb/xkb.c
+++ b/xkb/xkb.c
@@ -5510,10 +5510,8 @@ ProcXkbListComponents(ClientPtr client)
     if ((XkbPaddedSize(len)/4)!=stuff->length)
 	return BadLength;
     if ((status=XkbDDXList(dev,&list,client))!=Success) {
-	if (list.pool) {
-	    free(list.pool);
-	    list.pool= NULL;
-	}
+	free(list.pool);
+	list.pool = NULL;
 	return status;
     }
     memset(&rep, 0, sizeof(xkbListComponentsReply));
@@ -5886,11 +5884,16 @@ ProcXkbGetKbdByName(ClientPtr client)
 	XkbFreeKeyboard(new,XkbAllComponentsMask,TRUE);
 	new= NULL;
     }
-    if (names.keycodes)	{ free(names.keycodes); names.keycodes= NULL; }
-    if (names.types)	{ free(names.types); names.types= NULL; }
-    if (names.compat)	{ free(names.compat); names.compat= NULL; }
-    if (names.symbols)	{ free(names.symbols); names.symbols= NULL; }
-    if (names.geometry)	{ free(names.geometry); names.geometry= NULL; }
+    free(names.keycodes);
+    names.keycodes = NULL;
+    free(names.types);
+    names.types = NULL;
+    free(names.compat);
+    names.compat = NULL;
+    free(names.symbols);
+    names.symbols = NULL;
+    free(names.geometry);
+    names.geometry = NULL;
     return Success;
 }
 
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index bd58243..fbf8f14 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -635,10 +635,8 @@ unwind_key:
 void
 XkbFreeInfo(XkbSrvInfoPtr xkbi)
 {
-    if (xkbi->radioGroups) {
-	free(xkbi->radioGroups);
-	xkbi->radioGroups= NULL;
-    }
+    free(xkbi->radioGroups);
+    xkbi->radioGroups = NULL;
     if (xkbi->mouseKeyTimer) {
 	TimerFree(xkbi->mouseKeyTimer);
 	xkbi->mouseKeyTimer= NULL;
commit 89bd05106e5823fc5cfca9abf082729f2444363b
Author: Matt Turner <mattst88 at gmail.com>
Date:   Fri Jun 4 21:09:35 2010 -0400

    record: move free() to after last use of pContext
    
    No functional change, since free doesn't change the value of the pointer
    passed to it, but it makes this code less confusing.
    
    Reviewed-by: Jamey Sharp <jamey at minilop.net>
    Signed-off-by: Matt Turner <mattst88 at gmail.com>

diff --git a/record/record.c b/record/record.c
index 53bdfec..4117a5a 100644
--- a/record/record.c
+++ b/record/record.c
@@ -2520,8 +2520,6 @@ RecordDeleteContext(pointer value, XID id)
 	}
     }
 
-    free(pContext);
-
     /* remove context from AllContexts list */
 
     if (-1 != (i = RecordFindContextOnAllContexts(pContext)))
@@ -2533,6 +2531,8 @@ RecordDeleteContext(pointer value, XID id)
 	    ppAllContexts = NULL;
 	}
     }
+    free(pContext);
+
     return Success;
 } /* RecordDeleteContext */
 
commit a54a766dfb39fb3df671045878ac706215d83cef
Author: Mikhail Gusarov <dottedmag at dottedmag.net>
Date:   Mon Jun 7 03:19:03 2010 +0700

    xkb: replace xstrdup with strdup in Win32System
    
    The only caller of Win32System is XkbDDXCompileKeymapByNames. Add allocation
    check there to avoid passing NULL pointers to various functions down the code.
    
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index b1d6294..5e6ab87 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -103,7 +103,7 @@ Win32System(const char *cmdline)
     STARTUPINFO si;
     PROCESS_INFORMATION pi;
     DWORD dwExitCode;
-    char *cmd = xstrdup(cmdline);
+    char *cmd = strdup(cmdline);
 
     ZeroMemory( &si, sizeof(si) );
     si.cb = sizeof(si);
@@ -235,6 +235,11 @@ XkbDDXCompileKeymapByNames(	XkbDescPtr		xkb,
 		  xkm_output_dir, keymap);
 
     free(xkbbasedirflag);
+
+    if (!buf) {
+        LogMessage(X_ERROR, "XKB: Could not invoke xkbcomp: not enough memory\n");
+        return FALSE;
+    }
     
 #ifndef WIN32
     out= Popen(buf,"w");
commit 6e7417c342b0624e3f3c5686bb43026786423692
Author: Mikhail Gusarov <dottedmag at dottedmag.net>
Date:   Fri Jun 4 17:05:35 2010 +0700

    config: Replace xstrdup with strdup in add_option()
    
    All callers of add_option pass string literal as "key" argument
    except one, where non-NULL condition is guarded by if().
    
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/config/config.c b/config/config.c
index d42a16a..d86f7c6 100644
--- a/config/config.c
+++ b/config/config.c
@@ -133,7 +133,7 @@ add_option(InputOption **options, const char *key, const char *value)
     *options = calloc(sizeof(**options), 1);
     if (!*options) /* Yeesh. */
         return;
-    (*options)->key = xstrdup(key);
+    (*options)->key = strdup(key);
     (*options)->value = strdup(value);
     (*options)->next = NULL;
 }
commit e4570f5db5157f4233454c938733a2a0d6a1cb8f
Author: Mikhail Gusarov <dottedmag at dottedmag.net>
Date:   Fri Jun 4 17:01:42 2010 +0700

    xfree86: Get rid of xstrdup when argument is definitely non-NULL
    
    ditto for XFree86
    
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index 2f93bb1..822d767 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -277,16 +277,16 @@ configureInputSection (void)
     mouse->inp_identifier = "Mouse0";
     mouse->inp_driver = "mouse";
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, xstrdup("Protocol"),
-				xstrdup(DFLT_MOUSE_PROTO));
+		xf86addNewOption(mouse->inp_option_lst, strdup("Protocol"),
+				strdup(DFLT_MOUSE_PROTO));
 #ifndef __SCO__
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, xstrdup("Device"),
-				xstrdup(DFLT_MOUSE_DEV));
+		xf86addNewOption(mouse->inp_option_lst, strdup("Device"),
+				strdup(DFLT_MOUSE_DEV));
 #endif
     mouse->inp_option_lst = 
-		xf86addNewOption(mouse->inp_option_lst, xstrdup("ZAxisMapping"),
-				xstrdup("4 5 6 7"));
+		xf86addNewOption(mouse->inp_option_lst, strdup("ZAxisMapping"),
+				strdup("4 5 6 7"));
     ptr = (XF86ConfInputPtr)xf86addListItem((glp)ptr, (glp)mouse);
     return ptr;
 }
@@ -389,7 +389,7 @@ configureDeviceSection (int screennum)
 	    "        ### <string>: \"String\", <freq>: \"<f> Hz/kHz/MHz\",\n"
 	    "        ### <percent>: \"<f>%\"\n"
 	    "        ### [arg]: arg optional\n";
-	ptr->dev_comment = xstrdup(descrip);
+	ptr->dev_comment = strdup(descrip);
 	if (ptr->dev_comment) {
     	    for (p = DevToConfig[screennum].GDev.options;
 		 p->name != NULL; p++) {
@@ -440,7 +440,7 @@ configureLayoutSection (void)
 	iptr->iref_option_lst = NULL;
 	iptr->iref_inputdev_str = "Mouse0";
 	iptr->iref_option_lst =
-		xf86addNewOption (iptr->iref_option_lst, xstrdup("CorePointer"), NULL);
+		xf86addNewOption (iptr->iref_option_lst, strdup("CorePointer"), NULL);
 	ptr->lay_input_lst = (XF86ConfInputrefPtr)
 		xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
     }
@@ -453,7 +453,7 @@ configureLayoutSection (void)
 	iptr->iref_option_lst = NULL;
 	iptr->iref_inputdev_str = "Keyboard0";
 	iptr->iref_option_lst =
-		xf86addNewOption (iptr->iref_option_lst, xstrdup("CoreKeyboard"), NULL);
+		xf86addNewOption (iptr->iref_option_lst, strdup("CoreKeyboard"), NULL);
 	ptr->lay_input_lst = (XF86ConfInputrefPtr)
 		xf86addListItem ((glp) ptr->lay_input_lst, (glp) iptr);
     }
@@ -626,7 +626,7 @@ configureDDCMonitorSection (int screennum)
                              ptr);
 
     if (ConfiguredMonitor->features.dpms) {
-      ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, xstrdup("DPMS"), NULL);
+      ptr->mon_option_lst = xf86addNewOption(ptr->mon_option_lst, strdup("DPMS"), NULL);
     }
 
     return ptr;
diff --git a/hw/xfree86/common/xf86Option.c b/hw/xfree86/common/xf86Option.c
index 91a6718..aa6ea30 100644
--- a/hw/xfree86/common/xf86Option.c
+++ b/hw/xfree86/common/xf86Option.c
@@ -209,7 +209,7 @@ LookupStrOption(pointer optlist, const char *name, char *deflt, Bool markUsed)
     if (ParseOptionValue(-1, optlist, &o, markUsed))
         deflt = o.value.str;
     if (deflt)
-	return xstrdup(deflt);
+	return strdup(deflt);
     else
 	return NULL;
 }
diff --git a/hw/xfree86/loader/loadmod.c b/hw/xfree86/loader/loadmod.c
index 4962443..615e8c6 100644
--- a/hw/xfree86/loader/loadmod.c
+++ b/hw/xfree86/loader/loadmod.c
@@ -135,7 +135,7 @@ InitPathList(const char *path)
     if (!path)
 	return defaultPathList;
 
-    fullpath = xstrdup(path);
+    fullpath = strdup(path);
     if (!fullpath)
 	return NULL;
     elem = strtok(fullpath, ",");
@@ -353,7 +353,7 @@ InitSubdirs(const char **subdirlist)
 	    sprintf(subdirs[i], "%s%s%s/", *s, slash, osname);
 	    i++;
 	    /* path as given */
-	    subdirs[i] = xstrdup(*s);
+	    subdirs[i] = strdup(*s);
 	    i++;
 	    s++;
 	    if (indefault && !s) {
@@ -1246,7 +1246,7 @@ LoaderGetCanonicalName(const char *modname, PatternPtr patterns)
 	}
 
     /* If there is no match, return the whole name minus the leading path */
-    return xstrdup(s);
+    return strdup(s);
 }
 
 /*
commit 416d228481d71204cf9bfad3ab4773abc4757f79
Author: Mikhail Gusarov <dottedmag at dottedmag.net>
Date:   Fri Jun 4 17:01:25 2010 +0700

    xquartz: Get rid of xstrdup when argument is definitely non-NULL
    
    ditto for XQuartz
    
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xquartz/GL/indirect.c b/hw/xquartz/GL/indirect.c
index f769ff2..3e8d730 100644
--- a/hw/xquartz/GL/indirect.c
+++ b/hw/xquartz/GL/indirect.c
@@ -595,12 +595,12 @@ static __GLXscreen * __glXAquaScreenProbe(ScreenPtr pScreen) {
 
     __glXScreenInit(&screen->base, pScreen);
 
-    screen->base.GLXversion = xstrdup("1.4");
-    screen->base.GLXextensions = xstrdup("GLX_SGIX_fbconfig "
-					 "GLX_SGIS_multisample "
-					 "GLX_ARB_multisample "
-					 "GLX_EXT_visual_info "
-					 "GLX_EXT_import_context ");
+    screen->base.GLXversion = strdup("1.4");
+    screen->base.GLXextensions = strdup("GLX_SGIX_fbconfig "
+                                        "GLX_SGIS_multisample "
+                                        "GLX_ARB_multisample "
+                                        "GLX_EXT_visual_info "
+                                        "GLX_EXT_import_context ");
     
     /*We may be able to add more GLXextensions at a later time. */
     
commit eea286f2b9e4b1acf2b1c9800f5a4bc7c3fa968d
Author: Mikhail Gusarov <dottedmag at dottedmag.net>
Date:   Fri Jun 4 17:01:05 2010 +0700

    xwin: Get rid of xstrdup when argument is definitely non-NULL
    
    ditto for XWin
    
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 1ab059f..1b97606 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -441,7 +441,7 @@ winFixupPaths (void)
             int comment_block = FALSE;
 
             /* get defautl fontpath */
-            char *fontpath = xstrdup(defaultFontPath);
+            char *fontpath = strdup(defaultFontPath);
             size_t size = strlen(fontpath);
 
             /* read all lines */
@@ -528,7 +528,7 @@ winFixupPaths (void)
 
             /* cleanup */
             fclose(fontdirs);  
-            defaultFontPath = xstrdup(fontpath);
+            defaultFontPath = strdup(fontpath);
             free(fontpath);
             changed_fontpath = TRUE;
             font_from = X_CONFIG;
@@ -600,7 +600,7 @@ winFixupPaths (void)
             }
         } 
 
-        defaultFontPath = xstrdup(newfp);
+        defaultFontPath = strdup(newfp);
         free(newfp);
         changed_fontpath = TRUE;
     }
diff --git a/hw/xwin/glx/indirect.c b/hw/xwin/glx/indirect.c
index 5e0e917..8ec40da 100755
--- a/hw/xwin/glx/indirect.c
+++ b/hw/xwin/glx/indirect.c
@@ -676,7 +676,7 @@ glxWinScreenProbe(ScreenPtr pScreen)
       fbConfigsDump(screen->base.numFBConfigs, screen->base.fbconfigs);
 
       // Override the GL extensions string set by __glXScreenInit()
-      screen->base.GLextensions = xstrdup(gl_extensions);
+      screen->base.GLextensions = strdup(gl_extensions);
 
       // Generate the GLX extensions string (overrides that set by __glXScreenInit())
       {
@@ -706,13 +706,13 @@ glxWinScreenProbe(ScreenPtr pScreen)
 
           if (screen->has_WGL_ARB_multisample)
             {
-              screen->base.GLXversion = xstrdup("1.4");
+              screen->base.GLXversion = strdup("1.4");
               screen->base.GLXmajor = 1;
               screen->base.GLXminor = 4;
             }
           else
             {
-              screen->base.GLXversion = xstrdup("1.3");
+              screen->base.GLXversion = strdup("1.3");
               screen->base.GLXmajor = 1;
               screen->base.GLXminor = 3;
             }
diff --git a/hw/xwin/winconfig.c b/hw/xwin/winconfig.c
index ab49aaa..a88b6f1 100644
--- a/hw/xwin/winconfig.c
+++ b/hw/xwin/winconfig.c
@@ -583,7 +583,7 @@ winConfigFiles ()
   else if (filesptr != NULL && filesptr->file_fontpath)
     {
       from = X_CONFIG;
-      defaultFontPath = xstrdup (filesptr->file_fontpath);
+      defaultFontPath = strdup (filesptr->file_fontpath);
     }
   winMsg (from, "FontPath set to \"%s\"\n", defaultFontPath);
 
@@ -630,7 +630,7 @@ winSetStrOption (pointer optlist, const char *name, char *deflt)
   if (ParseOptionValue (-1, optlist, &o))
     deflt = o.value.str;
   if (deflt)
-    return xstrdup (deflt);
+    return strdup (deflt);
   else
     return NULL;
 }
commit dd45b7d74696cd4fe9545852640a3c2e66a808fd
Author: Mikhail Gusarov <dottedmag at dottedmag.net>
Date:   Fri Jun 4 17:00:46 2010 +0700

    kdrive: Get rid of xstrdup when argument is definitely non-NULL
    
    ditto for Kdrive
    
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/kdrive/src/kinput.c b/hw/kdrive/src/kinput.c
index 4024758..80a1458 100644
--- a/hw/kdrive/src/kinput.c
+++ b/hw/kdrive/src/kinput.c
@@ -919,7 +919,7 @@ KdAddConfigKeyboard (char *keyboard)
     if (!new)
         return BadAlloc;
 
-    new->line = xstrdup(keyboard);
+    new->line = strdup(keyboard);
     new->next = NULL;
 
     for (prev = &kdConfigKeyboards; *prev; prev = &(*prev)->next);
@@ -987,7 +987,7 @@ KdAddConfigPointer (char *pointer)
     if (!new)
         return BadAlloc;
 
-    new->line = xstrdup(pointer);
+    new->line = strdup(pointer);
     new->next = NULL;
 
     for (prev = &kdConfigPointers; *prev; prev = &(*prev)->next);
@@ -1067,11 +1067,11 @@ KdGetOptions (InputOption **options, char *string)
         newopt->key = (char *)malloc(tam_key);
         strncpy(newopt->key, string, tam_key);
         newopt->key[tam_key] = '\0';
-        newopt->value = xstrdup(strchr(string, '=') + 1);
+        newopt->value = strdup(strchr(string, '=') + 1);
     }
     else
     {
-        newopt->key = xstrdup(string);
+        newopt->key = strdup(string);
         newopt->value = NULL;
     }
     newopt->next = NULL;
@@ -1147,7 +1147,7 @@ KdParseKeyboard (char *arg)
     if (strcmp (save, "auto") == 0)
         ki->driverPrivate = NULL;
     else
-        ki->driverPrivate = xstrdup(save);
+        ki->driverPrivate = strdup(save);
 
     if (delim != ',')
     {
@@ -1243,7 +1243,7 @@ KdParsePointer (char *arg)
     if (strcmp(save, "auto") == 0)
         pi->driverPrivate = NULL;
     else
-        pi->driverPrivate = xstrdup(save);
+        pi->driverPrivate = strdup(save);
 
     if (delim != ',')
     {
commit 16158366954d945db6263f6de505fc02ee03c6cd
Author: Mikhail Gusarov <dottedmag at dottedmag.net>
Date:   Fri Jun 4 17:00:15 2010 +0700

    dmx: Get rid of xstrdup when argument is definitely non-NULL
    
    ditto for DMX
    
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/hw/dmx/input/dmxinputinit.c b/hw/dmx/input/dmxinputinit.c
index b2e16fb..83a2abb 100644
--- a/hw/dmx/input/dmxinputinit.c
+++ b/hw/dmx/input/dmxinputinit.c
@@ -885,7 +885,7 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI)
                         && dmxL->deviceId < 0) {
                         dmxL->deviceId   = devices[i].id;
                         dmxL->deviceName = (devices[i].name
-                                            ? xstrdup(devices[i].name)
+                                            ? strdup(devices[i].name)
                                             : NULL);
                     }
                 }
@@ -918,7 +918,7 @@ static void dmxInputScanForExtensions(DMXInputInfo *dmxInput, int doXI)
                         dmxLocal->sendsCore  = FALSE;
                         dmxLocal->deviceId   = devices[i].id;
                         dmxLocal->deviceName = (devices[i].name
-                                                ? xstrdup(devices[i].name)
+                                                ? strdup(devices[i].name)
                                                 : NULL);
                     }
                 }
diff --git a/hw/dmx/input/usb-keyboard.c b/hw/dmx/input/usb-keyboard.c
index dc575fe..9db1adb 100644
--- a/hw/dmx/input/usb-keyboard.c
+++ b/hw/dmx/input/usb-keyboard.c
@@ -439,6 +439,6 @@ void kbdUSBGetInfo(DevicePtr pDev, DMXLocalInitInfoPtr info)
     kbdUSBGetMap(pDev, &info->keySyms, info->modMap);
     info->focusClass       = 1;
     info->kbdFeedbackClass = 1;
-    info->names.keycodes   = xstrdup("powerpcps2");
+    info->names.keycodes   = strdup("powerpcps2");
     info->force            = 1;
 }
commit 6592db6bb526f0c43b4c7b55859c629709e039b4
Author: Mikhail Gusarov <dottedmag at dottedmag.net>
Date:   Fri Jun 4 16:58:58 2010 +0700

    Get rid of xstrdup when argument is definitely non-NULL
    
    Replace xstrdup with strdup when either constant string is
    being duplicated or argument is guarded by conditionals and
    obviously can't be NULL
    
    Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/config/config.c b/config/config.c
index 65ef679..d42a16a 100644
--- a/config/config.c
+++ b/config/config.c
@@ -134,6 +134,6 @@ add_option(InputOption **options, const char *key, const char *value)
     if (!*options) /* Yeesh. */
         return;
     (*options)->key = xstrdup(key);
-    (*options)->value = xstrdup(value);
+    (*options)->value = strdup(value);
     (*options)->next = NULL;
 }
diff --git a/config/dbus.c b/config/dbus.c
index b67fddb..34e3caa 100644
--- a/config/dbus.c
+++ b/config/dbus.c
@@ -86,8 +86,8 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
         return BadAlloc;
     }
 
-    options->key = xstrdup("_source");
-    options->value = xstrdup("client/dbus");
+    options->key = strdup("_source");
+    options->value = strdup("client/dbus");
     if (!options->key || !options->value) {
         ErrorF("[config/dbus] couldn't allocate first key/value pair\n");
         ret = BadAlloc;
@@ -120,7 +120,7 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
                    tmp);
             MALFORMED_MESSAGE();
         }
-        options->key = xstrdup(tmp);
+        options->key = strdup(tmp);
         if (!options->key) {
             ErrorF("[config/dbus] couldn't duplicate key!\n");
             ret = BadAlloc;
@@ -136,7 +136,7 @@ add_device(DBusMessage *message, DBusMessage *reply, DBusError *error)
         dbus_message_iter_get_basic(&subiter, &tmp);
         if (!tmp)
             MALFORMED_MESSAGE();
-        options->value = xstrdup(tmp);
+        options->value = strdup(tmp);
         if (!options->value) {
             ErrorF("[config/dbus] couldn't duplicate option!\n");
             ret = BadAlloc;
diff --git a/config/hal.c b/config/hal.c
index 8f9aeb8..b70488b 100644
--- a/config/hal.c
+++ b/config/hal.c
@@ -81,7 +81,7 @@ get_prop_string(LibHalContext *hal_ctx, const char *udi, const char *name)
     prop = libhal_device_get_property_string(hal_ctx, udi, name, NULL);
     LogMessageVerb(X_INFO, 10, "config/hal: getting %s on %s returned %s\n", name, udi, prop ? prop : "(null)");
     if (prop) {
-        ret = xstrdup(prop);
+        ret = strdup(prop);
         libhal_free_string(prop);
     }
     else {
@@ -156,13 +156,13 @@ device_added(LibHalContext *hal_ctx, const char *udi)
         LogMessage(X_WARNING,"config/hal: no driver or path specified for %s\n", udi);
         goto unwind;
     }
-    attrs.device = xstrdup(path);
+    attrs.device = strdup(path);
 
     name = get_prop_string(hal_ctx, udi, "info.product");
     if (!name)
-        name = xstrdup("(unnamed)");
+        name = strdup("(unnamed)");
     else
-        attrs.product = xstrdup(name);
+        attrs.product = strdup(name);
 
     attrs.vendor = get_prop_string(hal_ctx, udi, "info.vendor");
     hal_tags = get_prop_string(hal_ctx, udi, "input.tags");
@@ -211,8 +211,8 @@ device_added(LibHalContext *hal_ctx, const char *udi)
         goto unwind;
     }
 
-    options->key = xstrdup("_source");
-    options->value = xstrdup("server/hal");
+    options->key = strdup("_source");
+    options->value = strdup("server/hal");
     if (!options->key || !options->value) {
         LogMessage(X_ERROR, "config/hal: couldn't allocate first key/value pair\n");
         goto unwind;
@@ -387,7 +387,7 @@ device_added(LibHalContext *hal_ctx, const char *udi)
 
     for (; dev; dev = dev->next){
         free(dev->config_info);
-        dev->config_info = xstrdup(config_info);
+        dev->config_info = strdup(config_info);
     }
 
 unwind:
diff --git a/config/udev.c b/config/udev.c
index 16c4624..9934490 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -86,8 +86,8 @@ device_added(struct udev_device *udev_device)
     if (!options)
         return;
 
-    options->key = xstrdup("_source");
-    options->value = xstrdup("server/udev");
+    options->key = strdup("_source");
+    options->value = strdup("server/udev");
     if (!options->key || !options->value)
         goto unwind;
 
@@ -197,7 +197,7 @@ device_added(struct udev_device *udev_device)
 
     for (; dev; dev = dev->next) {
         free(dev->config_info);
-        dev->config_info = xstrdup(config_info);
+        dev->config_info = strdup(config_info);
     }
 
  unwind:
diff --git a/dix/dixfonts.c b/dix/dixfonts.c
index 6c90fb9..b51ad84 100644
--- a/dix/dixfonts.c
+++ b/dix/dixfonts.c
@@ -1836,7 +1836,7 @@ SetDefaultFontPath(char *path)
     if (!start) {
 	temp_path = Xprintf("%s%sbuilt-ins", path, *path ? "," : "");
     } else {
-	temp_path = xstrdup(path);
+	temp_path = strdup(path);
     }
     if (!temp_path)
         return BadAlloc;
diff --git a/glx/glxcmds.c b/glx/glxcmds.c
index 1d3be49..9e5b213 100644
--- a/glx/glxcmds.c
+++ b/glx/glxcmds.c
@@ -2433,7 +2433,7 @@ int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc)
     cl->GLClientminorVersion = req->minor;
     free(cl->GLClientextensions);
     buf = (const char *)(req+1);
-    cl->GLClientextensions = xstrdup(buf);
+    cl->GLClientextensions = strdup(buf);
 
     return Success;
 }
diff --git a/glx/glxscreens.c b/glx/glxscreens.c
index a5b61df..8515e14 100644
--- a/glx/glxscreens.c
+++ b/glx/glxscreens.c
@@ -356,9 +356,9 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
 	return;
 
     pGlxScreen->pScreen       = pScreen;
-    pGlxScreen->GLextensions  = xstrdup(GLServerExtensions);
-    pGlxScreen->GLXvendor     = xstrdup(GLXServerVendorName);
-    pGlxScreen->GLXextensions = xstrdup(GLXServerExtensions);
+    pGlxScreen->GLextensions  = strdup(GLServerExtensions);
+    pGlxScreen->GLXvendor     = strdup(GLXServerVendorName);
+    pGlxScreen->GLXextensions = strdup(GLXServerExtensions);
 
     /* All GLX providers must support all of the functionality required for at
      * least GLX 1.2.  If the provider supports a higher version, the GLXminor
diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 72dd546..3344e50 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -1761,15 +1761,15 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
                     if (sdoodad->any.type == XkbTextDoodad) {
                         if (sdoodad->text.text)
                             ddoodad->text.text =
-                             xstrdup(sdoodad->text.text);
+                             strdup(sdoodad->text.text);
                         if (sdoodad->text.font)
                             ddoodad->text.font =
-                             xstrdup(sdoodad->text.font);
+                             strdup(sdoodad->text.font);
                     }
                     else if (sdoodad->any.type == XkbLogoDoodad) {
                         if (sdoodad->logo.logo_name)
                             ddoodad->logo.logo_name =
-                             xstrdup(sdoodad->logo.logo_name);
+                             strdup(sdoodad->logo.logo_name);
                     }
                 }
                 dsection->overlays = NULL;
@@ -1832,14 +1832,14 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
                 memcpy(ddoodad , sdoodad, sizeof(XkbDoodadRec));
                 if (sdoodad->any.type == XkbTextDoodad) {
                     if (sdoodad->text.text)
-                        ddoodad->text.text = xstrdup(sdoodad->text.text);
+                        ddoodad->text.text = strdup(sdoodad->text.text);
                     if (sdoodad->text.font)
-                        ddoodad->text.font = xstrdup(sdoodad->text.font);
+                        ddoodad->text.font = strdup(sdoodad->text.font);
                 }
                 else if (sdoodad->any.type == XkbLogoDoodad) {
                     if (sdoodad->logo.logo_name)
                         ddoodad->logo.logo_name =
-                          xstrdup(sdoodad->logo.logo_name);
+                          strdup(sdoodad->logo.logo_name);
                 }
             }
 


More information about the xorg-commit mailing list