Skip to content

Commit 4459f7f

Browse files
author
jan.nijtmans
committed
Code cleanup in tkCanvas.c/tkMenubutton.c. Use more TCL_UNUSED()
1 parent 1eb0598 commit 4459f7f

File tree

6 files changed

+64
-115
lines changed

6 files changed

+64
-115
lines changed

generic/tkButton.c

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,35 +1092,35 @@ ConfigureButton(
10921092
} else {
10931093
Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder);
10941094
}
1095-
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->wrapLengthObj, &wrapLength);
1095+
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->wrapLengthObj, &wrapLength);
10961096
if (wrapLength < 0) {
10971097
wrapLength = 0;
10981098
Tcl_DecrRefCount(butPtr->wrapLengthObj);
10991099
butPtr->wrapLengthObj = Tcl_NewIntObj(0);
11001100
Tcl_IncrRefCount(butPtr->wrapLengthObj);
11011101
}
1102-
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &borderWidth);
1102+
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->borderWidthObj, &borderWidth);
11031103
if (borderWidth < 0) {
11041104
borderWidth = 0;
11051105
Tcl_DecrRefCount(butPtr->borderWidthObj);
11061106
butPtr->borderWidthObj = Tcl_NewIntObj(0);
11071107
Tcl_IncrRefCount(butPtr->borderWidthObj);
11081108
}
1109-
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &highlightWidth);
1109+
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthObj, &highlightWidth);
11101110
if (highlightWidth < 0) {
11111111
highlightWidth = 0;
11121112
Tcl_DecrRefCount(butPtr->highlightWidthObj);
11131113
butPtr->highlightWidthObj = Tcl_NewIntObj(0);
11141114
Tcl_IncrRefCount(butPtr->highlightWidthObj);
11151115
}
1116-
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &padX);
1116+
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padXObj, &padX);
11171117
if (padX < 0) {
11181118
padX = 0;
11191119
Tcl_DecrRefCount(butPtr->padXObj);
11201120
butPtr->padXObj = Tcl_NewIntObj(0);
11211121
Tcl_IncrRefCount(butPtr->padXObj);
11221122
}
1123-
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &padY);
1123+
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->padYObj, &padY);
11241124
if (padY < 0) {
11251125
padY = 0;
11261126
Tcl_DecrRefCount(butPtr->padYObj);
@@ -1727,14 +1727,12 @@ static char *
17271727
ButtonTextVarProc(
17281728
void *clientData, /* Information about button. */
17291729
Tcl_Interp *interp, /* Interpreter containing variable. */
1730-
const char *name1, /* Not used. */
1731-
const char *name2, /* Not used. */
1730+
TCL_UNUSED(const char *), /* name1 */
1731+
TCL_UNUSED(const char *), /* name2 */
17321732
int flags) /* Information about what happened. */
17331733
{
17341734
TkButton *butPtr = (TkButton *)clientData;
17351735
Tcl_Obj *valuePtr;
1736-
(void)name1;
1737-
(void)name2;
17381736

17391737
if (butPtr->flags & BUTTON_DELETED) {
17401738
return NULL;
@@ -1822,19 +1820,14 @@ ButtonTextVarProc(
18221820
static void
18231821
ButtonImageProc(
18241822
void *clientData, /* Pointer to widget record. */
1825-
int x, int y, /* Upper left pixel (within image) that must
1826-
* be redisplayed. */
1827-
int width, int height, /* Dimensions of area to redisplay (might be
1828-
* <= 0). */
1829-
int imgWidth, int imgHeight)/* New dimensions of image. */
1823+
TCL_UNUSED(int), /* x, Upper left pixel (within image) that must */
1824+
TCL_UNUSED(int), /* y, be redisplayed. */
1825+
TCL_UNUSED(int), /* width, Dimensions of area to redisplay (might be */
1826+
TCL_UNUSED(int), /* height, <= 0). */
1827+
TCL_UNUSED(int), /* imgWidth, New dimensions of image. */
1828+
TCL_UNUSED(int)) /* imgHeight */
18301829
{
18311830
TkButton *butPtr = (TkButton *)clientData;
1832-
(void)x;
1833-
(void)y;
1834-
(void)width;
1835-
(void)height;
1836-
(void)imgWidth;
1837-
(void)imgHeight;
18381831

18391832
if (butPtr->tkwin != NULL) {
18401833
TkpComputeButtonGeometry(butPtr);
@@ -1866,19 +1859,14 @@ ButtonImageProc(
18661859
static void
18671860
ButtonSelectImageProc(
18681861
void *clientData, /* Pointer to widget record. */
1869-
int x, int y, /* Upper left pixel (within image) that must
1870-
* be redisplayed. */
1871-
int width, int height, /* Dimensions of area to redisplay (might be
1872-
* <= 0). */
1873-
int imgWidth, int imgHeight)/* New dimensions of image. */
1862+
TCL_UNUSED(int), /* x, Upper left pixel (within image) that must */
1863+
TCL_UNUSED(int), /* y, be redisplayed. */
1864+
TCL_UNUSED(int), /* width, Dimensions of area to redisplay (might be */
1865+
TCL_UNUSED(int), /* height, <= 0). */
1866+
TCL_UNUSED(int), /* imgWidth, New dimensions of image. */
1867+
TCL_UNUSED(int)) /* imgHeight */
18741868
{
18751869
TkButton *butPtr = (TkButton *)clientData;
1876-
(void)x;
1877-
(void)y;
1878-
(void)width;
1879-
(void)height;
1880-
(void)imgWidth;
1881-
(void)imgHeight;
18821870

18831871
#ifdef MAC_OSX_TK
18841872
if (butPtr->tkwin != NULL) {
@@ -1919,19 +1907,14 @@ ButtonSelectImageProc(
19191907
static void
19201908
ButtonTristateImageProc(
19211909
void *clientData, /* Pointer to widget record. */
1922-
int x, int y, /* Upper left pixel (within image) that must
1923-
* be redisplayed. */
1924-
int width, int height, /* Dimensions of area to redisplay (might be
1925-
* <= 0). */
1926-
int imgWidth, int imgHeight)/* New dimensions of image. */
1910+
TCL_UNUSED(int), /* x, Upper left pixel (within image) that must */
1911+
TCL_UNUSED(int), /* y, be redisplayed. */
1912+
TCL_UNUSED(int), /* width, Dimensions of area to redisplay (might be */
1913+
TCL_UNUSED(int), /* height, <= 0). */
1914+
TCL_UNUSED(int), /* imgWidth, New dimensions of image. */
1915+
TCL_UNUSED(int)) /* imgHeight */
19271916
{
19281917
TkButton *butPtr = (TkButton *)clientData;
1929-
(void)x;
1930-
(void)y;
1931-
(void)width;
1932-
(void)height;
1933-
(void)imgWidth;
1934-
(void)imgHeight;
19351918

19361919
#ifdef MAC_OSX_TK
19371920
if (butPtr->tkwin != NULL) {

generic/tkCanvImg.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ static void
526526
DisplayImage(
527527
Tk_Canvas canvas, /* Canvas that contains item. */
528528
Tk_Item *itemPtr, /* Item to be displayed. */
529-
Display *display, /* Display on which to draw item. */
529+
TCL_UNUSED(Display *), /* Display on which to draw item. */
530530
Drawable drawable, /* Pixmap or window in which to draw item. */
531531
int x, int y, int width, int height)
532532
/* Describes region of canvas that must be
@@ -536,7 +536,6 @@ DisplayImage(
536536
short drawableX, drawableY;
537537
Tk_Image image;
538538
Tk_State state = itemPtr->state;
539-
(void)display;
540539

541540
if (state == TK_STATE_NULL) {
542541
state = Canvas(canvas)->canvas_state;

generic/tkCanvas.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,24 +2311,6 @@ ConfigureCanvas(
23112311
canvasPtr->highlightWidthObj = Tcl_NewIntObj(0);
23122312
Tcl_IncrRefCount(canvasPtr->highlightWidthObj);
23132313
}
2314-
if (canvasPtr->textInfo.insertBorderWidth < 0) {
2315-
canvasPtr->textInfo.insertBorderWidth = 0;
2316-
Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved1);
2317-
canvasPtr->textInfo.reserved1 = Tcl_NewIntObj(0);
2318-
Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved1);
2319-
}
2320-
if (canvasPtr->textInfo.insertWidth < 0) {
2321-
canvasPtr->textInfo.insertWidth = 0;
2322-
Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved2);
2323-
canvasPtr->textInfo.reserved2 = Tcl_NewIntObj(0);
2324-
Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved2);
2325-
}
2326-
if (canvasPtr->textInfo.selBorderWidth < 0) {
2327-
canvasPtr->textInfo.selBorderWidth = 0;
2328-
Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved3);
2329-
canvasPtr->textInfo.reserved3 = Tcl_NewIntObj(0);
2330-
Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved3);
2331-
}
23322314
if (width < 0) {
23332315
width = 0;
23342316
Tcl_DecrRefCount(canvasPtr->widthObj);
@@ -2350,12 +2332,21 @@ ConfigureCanvas(
23502332
canvasPtr->inset = borderWidth + highlightWidth;
23512333
if (canvasPtr->textInfo.insertBorderWidth < 0) {
23522334
canvasPtr->textInfo.insertBorderWidth = 0;
2335+
Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved1);
2336+
canvasPtr->textInfo.reserved1 = Tcl_NewIntObj(0);
2337+
Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved1);
23532338
}
23542339
if (canvasPtr->textInfo.insertWidth < 0) {
23552340
canvasPtr->textInfo.insertWidth = 0;
2341+
Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved2);
2342+
canvasPtr->textInfo.reserved2 = Tcl_NewIntObj(0);
2343+
Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved2);
23562344
}
23572345
if (canvasPtr->textInfo.selBorderWidth < 0) {
23582346
canvasPtr->textInfo.selBorderWidth = 0;
2347+
Tcl_DecrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved3);
2348+
canvasPtr->textInfo.reserved3 = Tcl_NewIntObj(0);
2349+
Tcl_IncrRefCount((Tcl_Obj *)canvasPtr->textInfo.reserved3);
23592350
}
23602351

23612352
gcValues.function = GXcopy;

generic/tkMenubutton.c

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,14 @@ static void DestroyMenuButton(void *memPtr);
190190

191191
int
192192
Tk_MenubuttonObjCmd(
193-
void *dummy, /* NULL. */
193+
TCL_UNUSED(void *),
194194
Tcl_Interp *interp, /* Current interpreter. */
195195
int objc, /* Number of arguments. */
196196
Tcl_Obj *const objv[]) /* Argument objects. */
197197
{
198198
TkMenuButton *mbPtr;
199199
Tk_OptionTable optionTable;
200200
Tk_Window tkwin;
201-
(void)dummy;
202201

203202
if (objc < 2) {
204203
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -544,36 +543,27 @@ ConfigureMenuButton(
544543
Tk_GetPixelsFromObj(NULL, mbPtr->tkwin, mbPtr->padYObj, &padY);
545544
if (borderWidth < 0) {
546545
borderWidth = 0;
547-
Tcl_DecrRefCount(mbPtr->borderWidthObj);
548-
mbPtr->borderWidthObj = Tcl_NewIntObj(0);
549-
Tcl_IncrRefCount(mbPtr->borderWidthObj);
546+
Tcl_DecrRefCount(mbPtr->borderWidthObj);
547+
mbPtr->borderWidthObj = Tcl_NewIntObj(0);
548+
Tcl_IncrRefCount(mbPtr->borderWidthObj);
550549
}
551550
if (highlightWidth < 0) {
552551
highlightWidth = 0;
553-
Tcl_DecrRefCount(mbPtr->highlightWidthObj);
554-
mbPtr->highlightWidthObj = Tcl_NewIntObj(0);
555-
Tcl_IncrRefCount(mbPtr->highlightWidthObj);
552+
Tcl_DecrRefCount(mbPtr->highlightWidthObj);
553+
mbPtr->highlightWidthObj = Tcl_NewIntObj(0);
554+
Tcl_IncrRefCount(mbPtr->highlightWidthObj);
556555
}
557556
if (padX < 0) {
558557
padX = 0;
559-
if (mbPtr->padXObj) {
560-
Tcl_DecrRefCount(mbPtr->padXObj);
561-
}
562-
mbPtr->padXObj = Tcl_NewIntObj(0);
563-
Tcl_IncrRefCount(mbPtr->padXObj);
558+
Tcl_DecrRefCount(mbPtr->padXObj);
559+
mbPtr->padXObj = Tcl_NewIntObj(0);
560+
Tcl_IncrRefCount(mbPtr->padXObj);
564561
}
565562
if (padY < 0) {
566563
padY = 0;
567-
if (mbPtr->padYObj) {
568-
Tcl_DecrRefCount(mbPtr->padYObj);
569-
}
570-
mbPtr->padYObj = Tcl_NewIntObj(0);
571-
Tcl_IncrRefCount(mbPtr->padYObj);
572-
if (mbPtr->padYObj) {
573-
Tcl_DecrRefCount(mbPtr->padYObj);
574-
}
575-
mbPtr->padYObj = Tcl_NewIntObj(0);
576-
Tcl_IncrRefCount(mbPtr->padYObj);
564+
Tcl_DecrRefCount(mbPtr->padYObj);
565+
mbPtr->padYObj = Tcl_NewIntObj(0);
566+
Tcl_IncrRefCount(mbPtr->padYObj);
577567
}
578568

579569
/*
@@ -971,19 +961,14 @@ MenuButtonTextVarProc(
971961
static void
972962
MenuButtonImageProc(
973963
void *clientData, /* Pointer to widget record. */
974-
int x, int y, /* Upper left pixel (within image) that must
975-
* be redisplayed. */
976-
int width, int height, /* Dimensions of area to redisplay (may be <=
977-
* 0). */
978-
int imgWidth, int imgHeight)/* New dimensions of image. */
964+
TCL_UNUSED(int), /* x, Upper left pixel (within image) that must */
965+
TCL_UNUSED(int), /* y, be redisplayed. */
966+
TCL_UNUSED(int), /* width, Dimensions of area to redisplay (may be <= */
967+
TCL_UNUSED(int), /* height, 0). */
968+
TCL_UNUSED(int), /* imgWidth, New dimensions of image. */
969+
TCL_UNUSED(int)) /* imgHeight */
979970
{
980971
TkMenuButton *mbPtr = (TkMenuButton *)clientData;
981-
(void)x;
982-
(void)y;
983-
(void)width;
984-
(void)height;
985-
(void)imgWidth;
986-
(void)imgHeight;
987972

988973
if (mbPtr->tkwin != NULL) {
989974
TkpComputeMenuButtonGeometry(mbPtr);

generic/tkPointer.c

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -416,23 +416,16 @@ int
416416
XGrabPointer(
417417
Display *display,
418418
Window grab_window,
419-
Bool owner_events,
420-
unsigned int event_mask,
421-
int pointer_mode,
422-
int keyboard_mode,
423-
Window confine_to,
424-
Cursor cursor,
425-
Time time)
419+
TCL_UNUSED(Bool), /* owner_events */
420+
TCL_UNUSED(unsigned int), /* event_mask */
421+
TCL_UNUSED(int), /* pointer_mode */
422+
TCL_UNUSED(int), /* keyboard_mode */
423+
TCL_UNUSED(Window), /* confine_to */
424+
TCL_UNUSED(Cursor), /* cursor */
425+
TCL_UNUSED(Time)) /* time */
426426
{
427427
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
428428
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
429-
(void)owner_events;
430-
(void)event_mask;
431-
(void)pointer_mode;
432-
(void)keyboard_mode;
433-
(void)confine_to;
434-
(void)cursor;
435-
(void)time;
436429

437430
LastKnownRequestProcessed(display)++;
438431
tsdPtr->grabWinPtr = (TkWindow *) Tk_IdToWindow(display, grab_window);
@@ -464,11 +457,10 @@ XGrabPointer(
464457
int
465458
XUngrabPointer(
466459
Display *display,
467-
Time time)
460+
TCL_UNUSED(Time)) /* time */
468461
{
469462
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
470463
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
471-
(void)time;
472464

473465
LastKnownRequestProcessed(display)++;
474466
tsdPtr->grabWinPtr = NULL;
@@ -588,12 +580,11 @@ int
588580
XDefineCursor(
589581
Display *display,
590582
Window w,
591-
Cursor cursor)
583+
TCL_UNUSED(Cursor)) /* cursor */
592584
{
593585
TkWindow *winPtr = (TkWindow *) Tk_IdToWindow(display, w);
594586
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
595587
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
596-
(void)cursor;
597588

598589
if (tsdPtr->cursorWinPtr == winPtr) {
599590
UpdateCursor(winPtr);

generic/tkStubInit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ doNothing(void)
5858
# define TkpRedrawWidget ((void (*)(Tk_Window))(void *)doNothing)
5959
# define TkpDefineNativeBitmaps ((void (*)(void))(void *)doNothing)
6060
# define TkpCreateNativeBitmap ((Pixmap (*)(Display *, const void *))(void *)doNothing)
61-
# define TkpGetNativeAppBitmap ((Pixmap (*)(Display *, const char*, int *, int *))(void *)doNothing)
61+
# define TkpGetNativeAppBitmap ((Pixmap (*)(Display *, const char *, int *, int *))(void *)doNothing)
6262
#endif
6363

6464
#ifdef _WIN32

0 commit comments

Comments
 (0)