Skip to content

Commit ce182e8

Browse files
committed
Merge branch 'uli42-pr/simplify_free' into 3.6.x
Attributes GH PR #555: #555
2 parents 3b640a0 + dc43f4c commit ce182e8

File tree

13 files changed

+58
-185
lines changed

13 files changed

+58
-185
lines changed

nx-X11/programs/Xserver/hw/nxagent/Args.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,8 @@ int ddxProcessArgument(int argc, char *argv[], int i)
729729
{
730730
int size;
731731

732-
if (nxagentKeyboard != NULL)
733-
{
734-
free(nxagentKeyboard);
735-
736-
nxagentKeyboard = NULL;
737-
}
732+
free(nxagentKeyboard);
733+
nxagentKeyboard = NULL;
738734

739735
if ((size = strlen(argv[i])) < 256)
740736
{

nx-X11/programs/Xserver/hw/nxagent/Clipboard.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -974,11 +974,8 @@ void nxagentNotifySelection(XEvent *X)
974974
}
975975

976976
/*
977-
* if (pszReturnData)
978-
* {
979-
* free(pszReturnData);
980-
* pszReturnData=NULL;
981-
* }
977+
* free(pszReturnData);
978+
* pszReturnData=NULL;
982979
*/
983980

984981
}
@@ -1500,11 +1497,8 @@ int nxagentInitClipboard(WindowPtr pWin)
15001497
fprintf(stderr, "nxagentInitClipboard: Got called.\n");
15011498
#endif
15021499

1503-
if (lastSelectionOwner != NULL)
1504-
{
1505-
free(lastSelectionOwner);
1506-
lastSelectionOwner = NULL;
1507-
}
1500+
free(lastSelectionOwner);
1501+
lastSelectionOwner = NULL;
15081502

15091503
lastSelectionOwner = (SelectionOwner *) malloc(2 * sizeof(SelectionOwner));
15101504

nx-X11/programs/Xserver/hw/nxagent/Colormap.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,7 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
257257
free(icws.cmapIDs);
258258

259259
if (!nxagentSameInstalledColormapWindows(icws.windows, icws.numWindows)) {
260-
if (nxagentOldInstalledColormapWindows)
261-
free(nxagentOldInstalledColormapWindows);
260+
free(nxagentOldInstalledColormapWindows);
262261

263262
#ifdef _XSERVER64
264263
{
@@ -318,13 +317,12 @@ void nxagentSetInstalledColormapWindows(ScreenPtr pScreen)
318317
#endif /* DUMB_WINDOW_MANAGERS */
319318
}
320319
else
321-
if (icws.windows) free(icws.windows);
320+
free(icws.windows);
322321
}
323322

324323
void nxagentSetScreenSaverColormapWindow(ScreenPtr pScreen)
325324
{
326-
if (nxagentOldInstalledColormapWindows)
327-
free(nxagentOldInstalledColormapWindows);
325+
free(nxagentOldInstalledColormapWindows);
328326

329327
#ifdef _XSERVER64
330328
{

nx-X11/programs/Xserver/hw/nxagent/Drawable.c

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
264264

265265
success = 0;
266266

267-
goto nxagentSynchronizeDrawableDataFree;
267+
goto nxagentSynchronizeDrawableDataEnd;
268268
}
269269

270270
ValidateGC(pDrawable, pGC);
@@ -282,7 +282,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
282282

283283
success = 1;
284284

285-
goto nxagentSynchronizeDrawableDataFree;
285+
goto nxagentSynchronizeDrawableDataEnd;
286286
}
287287
else if (nxagentReconnectTrap == 1)
288288
{
@@ -323,7 +323,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
323323

324324
success = 0;
325325

326-
goto nxagentSynchronizeDrawableDataFree;
326+
goto nxagentSynchronizeDrawableDataEnd;
327327
}
328328

329329
ValidateGC(pDrawable, pGC);
@@ -336,7 +336,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
336336

337337
success = 1;
338338

339-
goto nxagentSynchronizeDrawableDataFree;
339+
goto nxagentSynchronizeDrawableDataEnd;
340340
}
341341
else
342342
{
@@ -349,7 +349,7 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
349349

350350
success = 1;
351351

352-
goto nxagentSynchronizeDrawableDataFree;
352+
goto nxagentSynchronizeDrawableDataEnd;
353353
}
354354
}
355355
}
@@ -363,14 +363,8 @@ int nxagentSynchronizeDrawableData(DrawablePtr pDrawable, unsigned int breakMask
363363

364364
success = nxagentSynchronizeRegion(pDrawable, NullRegion, breakMask, owner);
365365

366-
nxagentSynchronizeDrawableDataFree:
367-
368-
if (data != NULL)
369-
{
370-
free(data);
371-
}
372-
373366
nxagentSynchronizeDrawableDataEnd:
367+
free(data);
374368

375369
return success;
376370
}
@@ -866,10 +860,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
866860
#endif
867861
}
868862

869-
if (cmpData != NULL)
870-
{
871-
free(cmpData);
872-
}
863+
free(cmpData);
873864
}
874865
}
875866
else
@@ -1066,10 +1057,7 @@ int nxagentSynchronizeRegion(DrawablePtr pDrawable, RegionPtr pRegion, unsigned
10661057
nxagentFreeRegion(pDrawable, clipRegion);
10671058
}
10681059

1069-
if (data != NULL)
1070-
{
1071-
free(data);
1072-
}
1060+
free(data);
10731061

10741062
RegionUninit(&exposeRegion);
10751063

nx-X11/programs/Xserver/hw/nxagent/Error.c

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static char nxagentRootDir[DEFAULT_STRING_LENGTH] = { 0 };
9898

9999
static char nxagentSessionDir[DEFAULT_STRING_LENGTH] = { 0 };
100100

101-
char *nxagentGetClientsPath(void);
101+
void nxagentGetClientsPath(void);
102102

103103
static int nxagentPrintError(Display *dpy, XErrorEvent *event, FILE *fp);
104104

@@ -247,16 +247,9 @@ int nxagentExitHandler(const char *message)
247247

248248
void nxagentOpenClientsLogFile()
249249
{
250-
char * clientsLogName;
251-
252250
if (*nxagentClientsLogName == '\0')
253251
{
254-
clientsLogName = nxagentGetClientsPath();
255-
256-
if (clientsLogName != NULL)
257-
{
258-
free(clientsLogName);
259-
}
252+
nxagentGetClientsPath();
260253
}
261254

262255
if (nxagentClientsLogName != NULL && *nxagentClientsLogName !='\0')
@@ -593,30 +586,27 @@ char *nxagentGetSessionPath(void)
593586
return sessionPath;
594587
}
595588

596-
char *nxagentGetClientsPath()
589+
void nxagentGetClientsPath()
597590
{
598-
char *sessionPath;
599-
char *clientsPath;
600591

601592
if (*nxagentClientsLogName == '\0')
602593
{
603-
sessionPath = nxagentGetSessionPath();
594+
char *sessionPath = nxagentGetSessionPath();
604595

605596
if (sessionPath == NULL)
606597
{
607-
return NULL;
598+
return;
608599
}
609600

610601
if (strlen(sessionPath) + strlen("/clients") > DEFAULT_STRING_LENGTH - 1)
611602
{
612603
#ifdef PANIC
613-
fprintf(stderr, "nxagentGetClientsPath: PANIC! Invalid value for the NX clients Log File Path '%s'.\n",
614-
nxagentClientsLogName);
604+
fprintf(stderr, "nxagentGetClientsPath: PANIC! Invalid value for the NX clients Log File Path ''.\n");
615605
#endif
616606

617607
free(sessionPath);
618608

619-
return NULL;
609+
return;
620610
}
621611

622612
strcpy(nxagentClientsLogName, sessionPath);
@@ -626,19 +616,6 @@ char *nxagentGetClientsPath()
626616
free(sessionPath);
627617
}
628618

629-
clientsPath = malloc(strlen(nxagentClientsLogName) + 1);
630-
631-
if (clientsPath == NULL)
632-
{
633-
#ifdef PANIC
634-
fprintf(stderr, "nxagentGetClientsPath: PANIC! Can't allocate memory for the clients Log File Path path.\n");
635-
#endif
636-
637-
return NULL;
638-
}
639-
640-
strcpy(clientsPath, nxagentClientsLogName);
641-
642-
return clientsPath;
619+
return;
643620
}
644621

nx-X11/programs/Xserver/hw/nxagent/Font.c

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -841,10 +841,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
841841

842842
for (j = 0; j < numSearchFields; j++)
843843
{
844-
if (searchFields[j] != NULL)
845-
{
846-
free(searchFields[j]);
847-
}
844+
free(searchFields[j]);
848845
}
849846
}
850847
}
@@ -863,10 +860,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
863860

864861
for (j = 0; j < numFontFields; j++)
865862
{
866-
if (fontNameFields[j] != NULL)
867-
{
868-
free(fontNameFields[j]);
869-
}
863+
free(fontNameFields[j]);
870864
}
871865

872866
return fontStruct;
@@ -1260,17 +1254,11 @@ static void nxagentFailedFontReconnect(FontPtr pFont, XID param1, void * param2)
12601254

12611255
static void nxagentFreeFailedToReconnectFonts()
12621256
{
1263-
if (nxagentFailedToReconnectFonts.font != NULL)
1264-
{
1265-
free(nxagentFailedToReconnectFonts.font);
1266-
nxagentFailedToReconnectFonts.font = NULL;
1267-
}
1257+
free(nxagentFailedToReconnectFonts.font);
1258+
nxagentFailedToReconnectFonts.font = NULL;
12681259

1269-
if (nxagentFailedToReconnectFonts.id != NULL)
1270-
{
1271-
free(nxagentFailedToReconnectFonts.id);
1272-
nxagentFailedToReconnectFonts.id = NULL;
1273-
}
1260+
free(nxagentFailedToReconnectFonts.id);
1261+
nxagentFailedToReconnectFonts.id = NULL;
12741262

12751263
nxagentFailedToReconnectFonts.size = 0;
12761264
nxagentFailedToReconnectFonts.index = 0;
@@ -1706,10 +1694,7 @@ int nxagentFreeFont(XFontStruct *fs)
17061694
#endif
17071695
}
17081696

1709-
if (fs -> properties)
1710-
{
1711-
free (fs->properties);
1712-
}
1697+
free (fs->properties);
17131698

17141699
XFree(fs);
17151700

nx-X11/programs/Xserver/hw/nxagent/GC.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -924,10 +924,7 @@ static void nxagentRestoreGCRec(struct nxagentGCRec *t)
924924
(void*)t, (void*)t -> gc);
925925
#endif
926926

927-
if (nxagentGC(t -> pGC))
928-
{
929-
free(nxagentGC(t -> pGC));
930-
}
927+
free(nxagentGC(t -> pGC));
931928

932929
nxagentGC(t -> pGC) = t -> gc;
933930

nx-X11/programs/Xserver/hw/nxagent/GCOps.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,10 +1545,7 @@ void nxagentFillPolygon(DrawablePtr pDrawable, GCPtr pGC, int shape,
15451545
RESET_GC_TRAP();
15461546
}
15471547

1548-
if (newPoints != NULL)
1549-
{
1550-
free(newPoints);
1551-
}
1548+
free(newPoints);
15521549
}
15531550

15541551
void nxagentPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,

nx-X11/programs/Xserver/hw/nxagent/Image.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,10 +1567,7 @@ FIXME: If we failed to encode the image by any of the available
15671567
nxagentImageStatistics.totalEncoded, nxagentImageStatistics.totalAdded);
15681568
#endif
15691569

1570-
if (packedChecksum != NULL)
1571-
{
1572-
free(packedChecksum);
1573-
}
1570+
free(packedChecksum);
15741571

15751572
if (packedImage != NULL)
15761573
{
@@ -1787,11 +1784,7 @@ int nxagentScaleImage(int x, int y, unsigned xRatio, unsigned yRatio,
17871784
}
17881785
}
17891786

1790-
if (image -> obdata != NULL)
1791-
{
1792-
free((char *) image -> obdata);
1793-
}
1794-
1787+
free((char *) image -> obdata);
17951788
free((char *) image);
17961789

17971790
*pImage = newImage;

nx-X11/programs/Xserver/hw/nxagent/Pixmap.c

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,10 +1172,7 @@ Bool nxagentCheckPixmapIntegrity(PixmapPtr pPixmap)
11721172
XDestroyImage(image);
11731173
}
11741174

1175-
if (data != NULL)
1176-
{
1177-
free(data);
1178-
}
1175+
free(data);
11791176
}
11801177
else
11811178
{
@@ -1421,10 +1418,7 @@ FIXME: If the pixmap has a different depth from the window, the
14211418
fprintf(stderr, "nxagentPixmapOnShadowDisplay: XCreateImage failed.\n");
14221419
#endif
14231420

1424-
if (data != NULL)
1425-
{
1426-
free(data);
1427-
}
1421+
free(data);
14281422

14291423
return False;
14301424
}
@@ -1583,10 +1577,7 @@ Bool nxagentFbOnShadowDisplay()
15831577
fprintf(stderr, "nxagentFbOnShadowDisplay: XCreateImage failed.\n");
15841578
#endif
15851579

1586-
if (data)
1587-
{
1588-
free(data);
1589-
}
1580+
free(data);
15901581

15911582
return False;
15921583
}

0 commit comments

Comments
 (0)