diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2020-06-18 18:34:59 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2020-06-18 18:34:59 -0400 |
commit | a9d6701d977700b18e31a70cc7982431bc702095 (patch) | |
tree | eb24677e90094a95c1461243b56e83309a47742b | |
parent | d2b4f0598086d4dd5caf3cdc218d0f97c37229ac (diff) |
fix the cppcheck style- and format-warnings
also bump version to 1.0.11.1, reflecting ongoing work since release
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/add_window.c | 9 | ||||
-rw-r--r-- | src/events.c | 40 | ||||
-rw-r--r-- | src/iconmgr.c | 26 | ||||
-rw-r--r-- | src/icons.c | 7 | ||||
-rw-r--r-- | src/list.c | 2 | ||||
-rw-r--r-- | src/menus.c | 83 | ||||
-rw-r--r-- | src/parse.c | 15 | ||||
-rw-r--r-- | src/resize.c | 7 | ||||
-rw-r--r-- | src/session.c | 8 | ||||
-rw-r--r-- | src/twm.c | 15 | ||||
-rw-r--r-- | src/util.c | 33 |
12 files changed, 146 insertions, 101 deletions
diff --git a/configure.ac b/configure.ac index 519f5cb..db01b62 100644 --- a/configure.ac +++ b/configure.ac @@ -22,7 +22,7 @@ dnl Process this file with autoconf to create configure. # Initialize Autoconf AC_PREREQ([2.60]) -AC_INIT([twm], [1.0.11], +AC_INIT([twm], [1.0.11.1], [https://gitlab.freedesktop.org/xorg/app/twm/issues], [twm]) AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_HEADERS([config.h]) diff --git a/src/add_window.c b/src/add_window.c index f919b77..e6bde43 100644 --- a/src/add_window.c +++ b/src/add_window.c @@ -147,11 +147,9 @@ TwmWindow * AddWindow(Window w, int iconm, IconMgr *iconp) { TwmWindow *tmp_win; /* new twm window structure */ - int stat; XEvent event; unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ - int width, height; /* tmp variable */ int ask_user; /* don't know where to put the window */ int gravx, gravy; /* gravity signs for positioning */ int namelen; @@ -289,12 +287,14 @@ AddWindow(Window w, int iconm, IconMgr *iconp) &tmp_win->class); if (tmp_win->auto_raise) Scr->NumAutoRaises++; - tmp_win->iconify_by_unmapping = Scr->IconifyByUnmapping; if (Scr->IconifyByUnmapping) { tmp_win->iconify_by_unmapping = iconm ? FALSE : !short_lookup LookInList(Scr->DontIconify, tmp_win->full_name, &tmp_win->class); } + else { + tmp_win->iconify_by_unmapping = Scr->IconifyByUnmapping; + } tmp_win->iconify_by_unmapping |= short_lookup LookInList(Scr->IconifyByUn, tmp_win->full_name, &tmp_win->class); @@ -427,11 +427,14 @@ AddWindow(Window w, int iconm, IconMgr *iconp) if (!(tmp_win->wmhints && tmp_win->wmhints->flags & StateHint && tmp_win->wmhints->initial_state == IconicState)) { Bool firsttime = True; + int height, width; /* better wait until all the mouse buttons have been * released. */ while (TRUE) { + int stat; + XUngrabServer(dpy); XSync(dpy, 0); XGrabServer(dpy); diff --git a/src/events.c b/src/events.c index 6c34261..9d92322 100644 --- a/src/events.c +++ b/src/events.c @@ -380,9 +380,8 @@ void HandleColormapNotify(void) { XColormapEvent *cevent = (XColormapEvent *) &Event; - ColormapWindow *cwin, **cwins; + ColormapWindow *cwin; TwmColormap *cmap; - int lost, won, n, number_cwins; XPointer context_data; if (XFindContext(dpy, cevent->window, ColormapContext, &context_data) == 0) @@ -430,6 +429,9 @@ HandleColormapNotify(void) } if (cevent->serial >= Scr->cmapInfo.first_req) { + ColormapWindow **cwins; + int lost, won, n, number_cwins; + number_cwins = Scr->cmapInfo.cmaps->number_cwins; /* @@ -698,13 +700,14 @@ free_window_names(TwmWindow *tmp, Bool nukefull, Bool nukename, Bool nukeicon) void free_cwins(TwmWindow *tmp) { - int i; - TwmColormap *cmap; - if (tmp->cmaps.number_cwins) { + int i; + for (i = 0; i < tmp->cmaps.number_cwins; i++) { + if (--tmp->cmaps.cwins[i]->refcnt == 0) { - cmap = tmp->cmaps.cwins[i]->colormap; + TwmColormap *cmap = tmp->cmaps.cwins[i]->colormap; + if (--cmap->refcnt == 0) { XDeleteContext(dpy, cmap->c, ColormapContext); free(cmap); @@ -714,6 +717,7 @@ free_cwins(TwmWindow *tmp) } } free(tmp->cmaps.cwins); + if (tmp->cmaps.number_cwins > 1) { free(tmp->cmaps.scoreboard); tmp->cmaps.scoreboard = NULL; @@ -729,7 +733,6 @@ void HandlePropertyNotify(void) { char *name = NULL; - unsigned long valuemask; /* mask for create windows */ XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm; @@ -894,6 +897,8 @@ HandlePropertyNotify(void) if (Tmp_win->icon_w && !Tmp_win->forced && Tmp_win->wmhints && (Tmp_win->wmhints->flags & IconPixmapHint)) { + unsigned long valuemask; /* mask for create windows */ + if (!XGetGeometry(dpy, Tmp_win->wmhints->icon_pixmap, &JunkRoot, &JunkX, &JunkY, (unsigned int *) &Tmp_win->icon_width, @@ -1167,7 +1172,6 @@ remove_window_from_ring(TwmWindow *tmp) void HandleDestroyNotify(void) { - int i; /* * Warning, this is also called by HandleUnmapNotify; if it ever needs to @@ -1198,7 +1202,10 @@ HandleDestroyNotify(void) XDeleteContext(dpy, Tmp_win->hilite_w, TwmContext); XDeleteContext(dpy, Tmp_win->hilite_w, ScreenContext); } + if (Tmp_win->titlebuttons) { + int i; + for (i = 0; i < nb; i++) { XDeleteContext(dpy, Tmp_win->titlebuttons[i].window, TwmContext); @@ -1279,7 +1286,6 @@ void HandleMapRequest(void) { XPointer context_data; - int zoom_save; Event.xany.window = Event.xmaprequest.window; if (XFindContext(dpy, Event.xany.window, TwmContext, &context_data) == 0) @@ -1309,6 +1315,7 @@ HandleMapRequest(void) if ((!Tmp_win->icon) && Tmp_win->wmhints && (Tmp_win->wmhints->flags & StateHint)) { int state; + int zoom_save; Window icon; /* use WM_STATE if enabled */ @@ -1484,7 +1491,6 @@ HandleMotionNotify(void) void HandleButtonRelease(void) { - int xl, xr, yt, yb, w, h; unsigned mask; XPointer context_data; @@ -1496,6 +1502,9 @@ HandleButtonRelease(void) } if (DragWindow != None) { + int xl, yt; + int w, h; + MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0); if (XFindContext(dpy, DragWindow, TwmContext, &context_data) == 0) @@ -1529,8 +1538,8 @@ HandleButtonRelease(void) } if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { - xr = xl + w; - yb = yt + h; + int xr = xl + w; + int yb = yt + h; if (xl < 0) xl = 0; @@ -2218,7 +2227,6 @@ void HandleConfigureRequest(void) { XWindowChanges xwc; - unsigned long xwcm; int x, y, width, height, bw; int gravx, gravy; XConfigureRequestEvent *cre = &Event.xconfigurerequest; @@ -2258,6 +2266,8 @@ HandleConfigureRequest(void) * to configuration requests for windows which have never been mapped. */ if (!Tmp_win || Tmp_win->icon_w == cre->window) { + unsigned long xwcm; + xwcm = cre->value_mask & (CWX | CWY | CWWidth | CWHeight | CWBorderWidth); xwc.x = cre->x; @@ -2420,10 +2430,12 @@ ScreenInfo * FindScreenInfo(Window w) { XWindowAttributes attr; - int scrnum; attr.screen = NULL; + if (XGetWindowAttributes(dpy, w, &attr)) { + int scrnum; + for (scrnum = 0; scrnum < NumScreens; scrnum++) { if (ScreenList[scrnum] != NULL && (ScreenOfDisplay(dpy, ScreenList[scrnum]->screen) == diff --git a/src/iconmgr.c b/src/iconmgr.c index e59f849..dcf0881 100644 --- a/src/iconmgr.c +++ b/src/iconmgr.c @@ -57,7 +57,6 @@ void CreateIconManagers(void) { IconMgr *p; - int mask; char str[100]; char str1[100]; Pixel background; @@ -74,9 +73,9 @@ CreateIconManagers(void) } for (p = &Scr->iconmgr; p != NULL; p = p->next) { - mask = XParseGeometry(p->geometry, &JunkX, &JunkY, - (unsigned int *) &p->width, - (unsigned int *) &p->height); + int mask = XParseGeometry(p->geometry, &JunkX, &JunkY, + (unsigned int *) &p->width, + (unsigned int *) &p->height); if (mask & XNegative) JunkX = Scr->MyDisplayWidth - p->width - @@ -129,7 +128,7 @@ AllocateIconManager(char *name, char *icon_name, char *geom, int columns) #ifdef DEBUG_ICONMGR fprintf(stderr, "AllocateIconManager\n"); fprintf(stderr, " name=\"%s\" icon_name=\"%s\", geom=\"%s\", col=%d\n", - name, icon_name, geom, columns); + name, icon_name ? icon_name : "<null>", geom, columns); #endif if (Scr->NoIconManagers) @@ -290,8 +289,6 @@ JumpIconManager(int dir) { IconMgr *ip, *tmp_ip = NULL; int got_it = FALSE; - ScreenInfo *sp; - int screen; if (!Active) return; @@ -309,8 +306,11 @@ JumpIconManager(int dir) if (!got_it) { int origscreen = ip->scr->screen; int inc = (dir == F_NEXTICONMGR ? 1 : -1); + int screen; for (screen = origscreen + inc;; screen += inc) { + ScreenInfo *sp; + if (screen >= NumScreens) screen = 0; else if (screen < 0) @@ -461,8 +461,8 @@ InsertInIconManager(IconMgr *ip, WList *tmp, TwmWindow *tmp_win) { WList *tmp1; int added; - int (*compar) (const char *, const char *) - = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); + int (*compar)(const char *, const char *) + =(Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); added = FALSE; if (ip->first == NULL) { @@ -594,8 +594,8 @@ SortIconManager(IconMgr *ip) { WList *tmp1, *tmp2; int done; - int (*compar) (const char *, const char *) - = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); + int (*compar)(const char *, const char *) + =(Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); if (ip == NULL) ip = Active->iconmgr; @@ -629,7 +629,6 @@ void PackIconManager(IconMgr *ip) { int newwidth, i, row, col, maxcol, colinc, rowinc, wheight, wwidth; - int new_x, new_y; int savewidth; WList *tmp; @@ -645,7 +644,10 @@ PackIconManager(IconMgr *ip) row = 0; col = ip->columns; maxcol = 0; + for (i = 0, tmp = ip->first; tmp != NULL; i++, tmp = tmp->next) { + int new_x, new_y; + tmp->me = i; if (++col >= ip->columns) { col = 0; diff --git a/src/icons.c b/src/icons.c index a437963..bf8d8aa 100644 --- a/src/icons.c +++ b/src/icons.c @@ -323,10 +323,11 @@ FreeIconEntries(IconRegion *ir) void FreeIconRegions(void) { - IconRegion *ir, *tmp; + IconRegion *ir; for (ir = Scr->FirstRegion; ir != NULL;) { - tmp = ir; + IconRegion *tmp = ir; + FreeIconEntries(ir); ir = ir->next; free(tmp); @@ -344,7 +345,6 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) XSetWindowAttributes attributes; /* attributes for create windows */ Pixmap pm = None; /* tmp pixmap variable */ int final_x, final_y; - int x; FB(tmp_win->iconc.fore, tmp_win->iconc.back); @@ -536,6 +536,7 @@ CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y) if (pm != None && (!(tmp_win->wmhints && tmp_win->wmhints->flags & IconWindowHint))) { int y; + int x; y = 0; if (tmp_win->icon_w_width == tmp_win->icon_width) @@ -93,7 +93,7 @@ AddToList(name_list ** list_head, char *name, char *ptr) nptr = malloc(sizeof(name_list)); if (nptr == NULL) { twmrc_error_prefix(); - fprintf(stderr, "unable to allocate %ld bytes for name_list\n", + fprintf(stderr, "unable to allocate %lu bytes for name_list\n", (unsigned long) sizeof(name_list)); Done(NULL, NULL); } diff --git a/src/menus.c b/src/menus.c index 8b1cb00..a0e5c0f 100644 --- a/src/menus.c +++ b/src/menus.c @@ -133,7 +133,7 @@ void InitMenus(void) { int i, j, k; - FuncKey *key, *tmp; + FuncKey *key; for (i = 0; i < MAX_BUTTONS + 1; i++) for (j = 0; j < NUM_CONTEXTS; j++) @@ -147,8 +147,9 @@ InitMenus(void) if (FirstScreen) { for (key = Scr->FuncKeyRoot.next; key != NULL;) { + FuncKey *tmp = key; + free(key->name); - tmp = key; key = key->next; free(tmp); } @@ -216,7 +217,7 @@ CreateTitleButton(const char *name, int func, const char *action, if (!tb) { fprintf(stderr, - "%s: unable to allocate %ld bytes for title button\n", + "%s: unable to allocate %lu bytes for title button\n", ProgramName, (unsigned long) sizeof(TitleButton)); return 0; } @@ -366,7 +367,6 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) text_y = y_offset + Scr->MenuFont.y; if (mi->func != F_TITLE) { - int x, y; if (mi->state) { XSetForeground(dpy, Scr->NormalGC, mi->hi_back); @@ -401,6 +401,8 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) } if (mi->func == F_MENU) { + int x, y; + /* create the pull right pixmap if needed */ if (Scr->pullPm == None) { Scr->pullPm = CreateMenuIcon(Scr->MenuFont.height, @@ -414,8 +416,6 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) } } else { - int y; - XSetForeground(dpy, Scr->NormalGC, mi->back); /* fill the rectangle with the title background color */ @@ -423,6 +423,8 @@ PaintEntry(MenuRoot *mr, MenuItem *mi, int exposure) (unsigned) mr->width, (unsigned) Scr->EntryHeight); { + int y; + XSetForeground(dpy, Scr->NormalGC, mi->fore); /* now draw the dividing lines */ if (y_offset) @@ -658,8 +660,8 @@ AddToMenu(MenuRoot *menu, const char *item, const char *action, int width; #ifdef DEBUG_MENUS - fprintf(stderr, "adding menu item=\"%s\", action=%s, sub=%d, f=%d\n", - item, action, sub, func); + fprintf(stderr, "adding menu item=\"%s\", action=%s, sub=%p, f=%d\n", + item, action ? action : "<null>", sub, func); #endif tmp = malloc(sizeof(MenuItem)); @@ -731,18 +733,17 @@ MakeMenu(MenuRoot *mr) XColor f1, f2, f3; XColor b1, b2, b3; XColor save_fore, save_back; - int num, i; - int fred, fgreen, fblue; - int bred, bgreen, bblue; - int width; - unsigned long valuemask; + int i; XSetWindowAttributes attributes; Colormap cmap = Scr->TwmRoot.cmaps.cwins[0]->colormap->c; Scr->EntryHeight = Scr->MenuFont.height + 4; - /* lets first size the window accordingly */ + /* let's first size the window accordingly */ if (mr->mapped == NEVER_MAPPED) { + int width; + unsigned long valuemask; + if (mr->pull == TRUE) { mr->width = (short) (mr->width + (16 + 10)); } @@ -837,7 +838,12 @@ MakeMenu(MenuRoot *mr) return; start = mr->first; + while (TRUE) { + int num; + int fred, fgreen, fblue; + int bred, bgreen, bblue; + for (; start != NULL; start = start->next) { if (start->user_colors) break; @@ -915,10 +921,8 @@ MakeMenu(MenuRoot *mr) Bool PopUpMenu(MenuRoot *menu, int x, int y, Bool center) { - int WindowNameCount; TwmWindow **WindowNames; TwmWindow *tmp_win2, *tmp_win3; - int i; int (*compar)(const char *, const char *) = (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1); @@ -929,6 +933,7 @@ PopUpMenu(MenuRoot *menu, int x, int y, Bool center) if (menu == Scr->Windows) { TwmWindow *tmp_win; + int WindowNameCount; /* this is the twm windows menu, let's go ahead and build it */ @@ -945,10 +950,14 @@ PopUpMenu(MenuRoot *menu, int x, int y, Bool center) for (tmp_win = Scr->TwmRoot.next, WindowNameCount = 0; tmp_win != NULL; tmp_win = tmp_win->next) WindowNameCount++; + if (WindowNameCount != 0) { + int i; + WindowNames = malloc(sizeof(TwmWindow *) * (size_t) WindowNameCount); WindowNames[0] = Scr->TwmRoot.next; + for (tmp_win = Scr->TwmRoot.next->next, WindowNameCount = 1; tmp_win != NULL; tmp_win = tmp_win->next, WindowNameCount++) { tmp_win2 = tmp_win; @@ -1687,7 +1696,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, } if (ConstMoveDir != MOVE_NONE) { - int xl, yt, xr, yb, w2, h; + int xl, yt, w2, h; xl = ConstMoveX; yt = ConstMoveY; @@ -1695,8 +1704,8 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, h = (int) ((unsigned) DragHeight + 2 * JunkBW); if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { - xr = xl + w2; - yb = yt + h; + int xr = xl + w2; + int yb = yt + h; if (xl < 0) xl = 0; @@ -1719,7 +1728,7 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, } } else if (DragWindow != None) { - int xl, yt, xr, yb, w2, h; + int xl, yt, w2, h; if (!menuFromFrameOrWindowOrTitlebar) { xl = (int) ((unsigned) eventp->xmotion.x_root - @@ -1735,8 +1744,8 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, h = (int) ((unsigned) DragHeight + 2 * JunkBW); if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE) { - xr = xl + w2; - yb = yt + h; + int xr = xl + w2; + int yb = yt + h; if (xl < 0) xl = 0; @@ -1994,7 +2003,6 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, case F_WARPNEXT: { register TwmWindow *t; - static TwmWindow *savedwarp = NULL; TwmWindow *of, *l, *n; int c = 0; @@ -2019,9 +2027,12 @@ ExecuteFunction(int func, const char *action, Window w, TwmWindow *tmp_win, if (t == of) c++; - if (bwin(t) || c >= 2) + if (bwin(t) || c >= 2) { Bell(XkbBI_MinorError, 0, None); + } else { + static TwmWindow *savedwarp = NULL; + if (of && of == savedwarp) { Iconify(of, 0, 0); savedwarp = NULL; @@ -2301,7 +2312,7 @@ Execute(const char *s) static char *exec_display; char *ds = DisplayString(dpy); - char *colon, *dot1; + char *colon; char *oldDisplay = NULL; char *value; Bool restorevar = False; @@ -2321,6 +2332,8 @@ Execute(const char *s) char *update = malloc(need); if (update != NULL) { + char *dot1; + strcpy(update, display_eqls); strcat(update, ds); colon = strrchr(update, ':'); @@ -2529,7 +2542,7 @@ Iconify(TwmWindow *tmp_win, int def_x, int def_y) static void Identify(TwmWindow *t) { - int i, n, twidth, width, height; + int i, n, width, height; int x, y; unsigned int wwidth, wheight, bw, depth; Window junk; @@ -2552,9 +2565,9 @@ Identify(TwmWindow *t) "Class.res_class = \"%s\"", t->class.res_class); Info[n++][0] = '\0'; snprintf(Info[n++], INFO_SIZE, - "Geometry/root = %dx%d+%d+%d", wwidth, wheight, x, y); - snprintf(Info[n++], INFO_SIZE, "Border width = %d", bw); - snprintf(Info[n++], INFO_SIZE, "Depth = %d", depth); + "Geometry/root = %ux%u+%d+%d", wwidth, wheight, x, y); + snprintf(Info[n++], INFO_SIZE, "Border width = %u", bw); + snprintf(Info[n++], INFO_SIZE, "Depth = %u", depth); if (HasSync) { int priority; @@ -2570,8 +2583,9 @@ Identify(TwmWindow *t) height = n * (Scr->DefaultFont.height + 2); width = 1; for (i = 0; i < n; i++) { - twidth = MyFont_TextWidth(&Scr->DefaultFont, Info[i], - (int) strlen(Info[i])); + int twidth = MyFont_TextWidth(&Scr->DefaultFont, Info[i], + (int) strlen(Info[i])); + if (twidth > width) width = twidth; } @@ -2685,7 +2699,6 @@ WarpToScreen(int n, int inc) static void BumpWindowColormap(TwmWindow *tmp, int inc) { - int i, j, previously_installed; ColormapWindow **cwins; if (!tmp) @@ -2695,6 +2708,9 @@ BumpWindowColormap(TwmWindow *tmp, int inc) cwins = malloc(sizeof(ColormapWindow *) * (size_t) tmp->cmaps.number_cwins); if (cwins) { + int i; + int previously_installed; + /* SUPPRESS 560 */ if ((previously_installed = (Scr->cmapInfo.cmaps == &tmp->cmaps && tmp->cmaps.number_cwins))) { @@ -2703,7 +2719,8 @@ BumpWindowColormap(TwmWindow *tmp, int inc) } for (i = 0; i < tmp->cmaps.number_cwins; i++) { - j = i - inc; + int j = i - inc; + if (j >= tmp->cmaps.number_cwins) j -= tmp->cmaps.number_cwins; else if (j < 0) diff --git a/src/parse.c b/src/parse.c index d81c2f3..df6cce3 100644 --- a/src/parse.c +++ b/src/parse.c @@ -82,7 +82,7 @@ static unsigned char overflowbuff[20]; /* really only need one */ static int overflowlen; static unsigned char **stringListSource, *currentString; -static int doparse(int (*ifunc) (void), const char *srctypename, +static int doparse(int (*ifunc)(void), const char *srctypename, const char *srcname); static int twmFileInput(void); static int twmStringListInput(void); @@ -93,14 +93,14 @@ extern int yylineno; int ConstrainedMoveTime = 400; /* milliseconds, event times */ -int (*twmInputFunc) (void); +int (*twmInputFunc)(void); /** * parse the .twmrc file * \param filename the filename to parse. NULL indicates $HOME/.twmrc */ static int -doparse(int (*ifunc) (void), const char *srctypename, const char *srcname) +doparse(int (*ifunc)(void), const char *srctypename, const char *srcname) { mods = 0; ptr = 0; @@ -983,19 +983,20 @@ do_color_keyword(int keyword, int colormode, char *s) static void put_pixel_on_root(Pixel pixel) { - int i, addPixel = 1; + int addPixel = 1; Atom pixelAtom, retAtom; int retFormat; unsigned long nPixels, retAfter; unsigned char *retProp; - Pixel *pixelProp; pixelAtom = XInternAtom(dpy, "_MIT_PRIORITY_COLORS", True); if (XGetWindowProperty(dpy, Scr->Root, pixelAtom, 0, 8192, False, XA_CARDINAL, &retAtom, &retFormat, &nPixels, &retAfter, &retProp) == Success) { - pixelProp = (Pixel *) retProp; + int i; + Pixel *pixelProp = (Pixel *) retProp; + for (i = 0; (unsigned long) i < nPixels; i++) if (pixel == pixelProp[i]) addPixel = 0; @@ -1159,7 +1160,7 @@ do_squeeze_entry(name_list ** list, char *name, int justify, int num, int denom) if (!sinfo) { twmrc_error_prefix(); - fprintf(stderr, "unable to allocate %ld bytes for squeeze info\n", + fprintf(stderr, "unable to allocate %lu bytes for squeeze info\n", (unsigned long) sizeof(SqueezeInfo)); return; } diff --git a/src/resize.c b/src/resize.c index 07a1015..dce406d 100644 --- a/src/resize.c +++ b/src/resize.c @@ -608,7 +608,7 @@ ConstrainSize(TwmWindow *tmp_win, int *widthp, int *heightp) #define makemult(a,b) ((b==1) ? (a) : (((int)((a)/(b))) * (b)) ) #define _min(a,b) (((a) < (b)) ? (a) : (b)) - int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc, delta; + int minWidth, minHeight, maxWidth, maxHeight, xinc, yinc; int baseWidth, baseHeight; int dwidth = *widthp, dheight = *heightp; @@ -694,6 +694,8 @@ ConstrainSize(TwmWindow *tmp_win, int *widthp, int *heightp) */ if (tmp_win->hints.flags & PAspect) { + int delta; + if (minAspectX * dheight > minAspectY * dwidth) { delta = makemult(minAspectX * dheight / minAspectY - dwidth, xinc); if (dwidth + delta <= maxWidth) @@ -914,7 +916,6 @@ fullzoom(TwmWindow *tmp_win, int flag) Window junkRoot; unsigned int junkbw, junkDepth; int basex, basey; - int frame_bw_times_2; XGetGeometry(dpy, (Drawable) tmp_win->frame, &junkRoot, &dragx, &dragy, (unsigned int *) &dragWidth, @@ -931,6 +932,8 @@ fullzoom(TwmWindow *tmp_win, int flag) tmp_win->zoomed = ZOOM_NONE; } else { + int frame_bw_times_2; + if (tmp_win->zoomed == ZOOM_NONE) { tmp_win->save_frame_x = dragx; tmp_win->save_frame_y = dragy; diff --git a/src/session.c b/src/session.c index ed8bb33..94b4d63 100644 --- a/src/session.c +++ b/src/session.c @@ -274,7 +274,7 @@ WriteWinConfigEntry(FILE *configFile, TwmWindow *theWindow, char *clientId, char *windowRole) { char **wm_command; - int wm_command_count, i; + int wm_command_count; if (!write_counted_string(configFile, clientId)) return 0; @@ -311,6 +311,8 @@ WriteWinConfigEntry(FILE *configFile, TwmWindow *theWindow, return 0; } else { + int i; + if (!write_byte(configFile, (unsigned char) wm_command_count)) return 0; for (i = 0; i < wm_command_count; i++) @@ -574,12 +576,14 @@ GetWindowConfig(TwmWindow *theWindow, */ char **wm_command = NULL; - int wm_command_count = 0, i; + int wm_command_count = 0; XGetCommand(dpy, theWindow->w, &wm_command, &wm_command_count); if (wm_command_count == ptr->wm_command_count) { + int i; + for (i = 0; i < wm_command_count; i++) if (strcmp(wm_command[i], ptr->wm_command[i]) != 0) @@ -183,12 +183,12 @@ static char *atom_names[11] = { /* |hasExtension()| and |IsPrintScreen()| have been stolen from * xc/programs/xdpyinfo/xdpyinfo.c */ static Bool -hasExtension(Display *dpy, char *extname) +hasExtension(Display *dpy2, char *extname) { int num_extensions, i; char **extensions; - extensions = XListExtensions(dpy, &num_extensions); + extensions = XListExtensions(dpy2, &num_extensions); for (i = 0; i < num_extensions && (strcmp(extensions[i], extname) != 0); i++); XFreeExtensionList(extensions); @@ -198,15 +198,15 @@ hasExtension(Display *dpy, char *extname) static Bool IsPrintScreen(Screen *s) { - Display *dpy = XDisplayOfScreen(s); - int i; + Display *dpy2 = XDisplayOfScreen(s); /* Check whether this is a screen of a print DDX */ - if (hasExtension(dpy, XP_PRINTNAME)) { + if (hasExtension(dpy2, XP_PRINTNAME)) { Screen **pscreens; int pscrcount; + int i; - pscreens = XpQueryScreens(dpy, &pscrcount); + pscreens = XpQueryScreens(dpy2, &pscrcount); for (i = 0; (i < pscrcount) && pscreens; i++) { if (s == pscreens[i]) { return True; @@ -889,11 +889,12 @@ void RestoreWithdrawnLocation(TwmWindow *tmp) { int gravx, gravy; - unsigned int bw, mask; + unsigned int bw; XWindowChanges xwc; if (XGetGeometry(dpy, tmp->w, &JunkRoot, &xwc.x, &xwc.y, &JunkWidth, &JunkHeight, &bw, &JunkDepth)) { + unsigned mask; GetGravityOffsets(tmp, &gravx, &gravy); if (gravy < 0) @@ -260,7 +260,7 @@ ExpandFilename(const char *name) newname = malloc((size_t) HomeLen + strlen(name) + 2); if (!newname) { fprintf(stderr, - "%s: unable to allocate %ld bytes to expand filename %s/%s\n", + "%s: unable to allocate %lu bytes to expand filename %s/%s\n", ProgramName, (unsigned long) HomeLen + (unsigned long) strlen(name) + 2, Home, &name[1]); @@ -398,7 +398,7 @@ InsertRGBColormap(Atom a, XStandardColormap *maps, int nmaps, Bool replace) if (!sc) { /* no existing, allocate new */ sc = malloc(sizeof(StdCmap)); if (!sc) { - fprintf(stderr, "%s: unable to allocate %ld bytes for StdCmap\n", + fprintf(stderr, "%s: unable to allocate %lu bytes for StdCmap\n", ProgramName, (unsigned long) sizeof(StdCmap)); return; } @@ -585,12 +585,13 @@ FindFontSet(MyFont *font, const char *fontname) XFontSetExtents *font_extents; XFontStruct **xfonts; char **font_names; - register int i; - int ascent; - int descent; - int fnum; if (use_fontset) { + int ascent; + int descent; + int fnum; + register int i; + if (font->fontset != NULL) { XFreeFontSet(dpy, font->fontset); } @@ -648,10 +649,10 @@ FindFontSet(MyFont *font, const char *fontname) void GetFont(MyFont *font) { - const char *deffontname = "fixed"; if (!FindFontSet(font, font->name)) { const char *what = "fonts"; + const char *deffontname = "fixed"; if (use_fontset) { what = "fontsets"; @@ -952,15 +953,6 @@ Pixmap CreateMenuIcon(int height, unsigned *widthp, unsigned *heightp) { int h, w; - int ih, iw; - int ix, iy; - int mh, mw; - int tw, th; - int lw, lh; - int lx, ly; - int lines, dly; - int off; - int bw; h = height; w = h * 7 / 8; @@ -973,6 +965,15 @@ CreateMenuIcon(int height, unsigned *widthp, unsigned *heightp) if (Scr->tbpm.menu == None) { Pixmap pix; GC gc; + int ih, iw; + int ix, iy; + int mh, mw; + int tw, th; + int lw, lh; + int lx, ly; + int lines, dly; + int off; + int bw; pix = Scr->tbpm.menu = XCreatePixmap(dpy, Scr->Root, (unsigned) w, (unsigned) h, 1); |