File: cppcheck.patch

package info (click to toggle)
alttab 1.7.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,828 kB
  • sloc: ansic: 4,263; sh: 1,825; makefile: 17
file content (153 lines) | stat: -rw-r--r-- 6,186 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
Description: Fix some problems reported by cppcheck.
Forwarded: no
Author: Peter Pentchev <roam@ringlet.net>
Last-Update: 2022-08-11

--- a/src/icon.c
+++ b/src/icon.c
@@ -495,7 +495,7 @@
     char appl[MAXAPPLEN];
     int l;
 
-    for (l = 0; (*(app + l)) != '\0' && l < MAXAPPLEN; l++)
+    for (l = 0; (*(app + l)) != '\0' && l < MAXAPPLEN - 1; l++)
         appl[l] = tolower(*(app + l));
     appl[l] = '\0';
 
--- a/src/win.c
+++ b/src/win.c
@@ -86,7 +86,7 @@
     int wi, si;
     PermanentWindowInfo *s;
 
-    if (g.winlist == NULL && g.maxNdx == 0)
+    if (g.winlist == NULL || g.maxNdx == 0)
         return;                 // safety
     msg(0, "winlist:\n");
     for (wi = 0; wi < g.maxNdx; wi++) {
@@ -497,7 +497,7 @@
     switch(g.option_bottom_line) {
         case BL_DESKTOP:
             if (desktop != DESKTOP_UNKNOWN)
-                snprintf(WI.bottom_line, MAXNAMESZ, "%ld", desktop);
+                snprintf(WI.bottom_line, MAXNAMESZ, "%lu", desktop);
             else
                 strncpy(WI.bottom_line, "?", 2);
             break;
@@ -508,7 +508,7 @@
                 strncpy(WI.bottom_line, "[no pid]", 9);
                 break;
             }
-            snprintf(procd, 32, "/proc/%ld", *pid);
+            snprintf(procd, 32, "/proc/%lu", *pid);
             sr = stat(procd, &st);
             if (sr == -1) {
                 strncpy(WI.bottom_line, "[no /proc]", 11);
@@ -752,16 +752,16 @@
             window_desktop, current_desktop);
         return true;
     }
-    if (g.option_desktop == DESK_NOSPECIAL && window_desktop == -1) {
+    if (g.option_desktop == DESK_NOSPECIAL && window_desktop == (unsigned long)-1) {
         msg(1, "window on -1 desktop, skipped\n");
         return true;
     }
     if (g.option_desktop == DESK_NOCURRENT &&
-        (window_desktop == current_desktop || window_desktop == -1)) {
+        (window_desktop == current_desktop || window_desktop == (unsigned long)-1)) {
         msg(1, "window on current or -1 desktop, skipped\n");
         return true;
     }
-    if (g.option_desktop == DESK_SPECIAL && window_desktop != -1) {
+    if (g.option_desktop == DESK_SPECIAL && window_desktop != (unsigned long)-1) {
         msg(1, "window not on -1 desktop, skipped\n");
         return true;
     }
--- a/src/autil.c
+++ b/src/autil.c
@@ -69,13 +69,13 @@
     switch (signum) {
         case SIGUSR1:
             fprintf(stderr, "debug information:\n");
-            fprintf(stderr, "winlist: %d elements of %ld bytes, %ld total\n",
+            fprintf(stderr, "winlist: %d elements of %zu bytes, %zu total\n",
                     g.maxNdx, sizeof(WindowInfo), g.maxNdx*sizeof(WindowInfo) );
             DL_COUNT(g.sortlist, pwi, sln);
-            fprintf(stderr, "sortlist: %d elements of %ld bytes, %ld total\n",
+            fprintf(stderr, "sortlist: %d elements of %zu bytes, %zu total\n",
                     sln, sizeof(PermanentWindowInfo), sln*sizeof(PermanentWindowInfo) );
             in = HASH_COUNT(g.ic);
-            fprintf(stderr, "icons: %d elements of %ld bytes, %ld total\n",
+            fprintf(stderr, "icons: %d elements of %zu bytes, %zu total\n",
                     in, sizeof(icon_t), in*sizeof(icon_t) );
             fprintf(stderr, "option_wm: %d, option_desktop: %d, option_screen: %d\n",
                     g.option_wm, g.option_desktop, g.option_screen);
--- a/src/ewmh.c
+++ b/src/ewmh.c
@@ -91,7 +91,7 @@
 {
     int evr, elapsed;
     unsigned long edata[] = { desktop, CurrentTime, 0, 0, 0 };
-    if (desktop == -1 && g.ewmh.minus1_desktop_unusable)
+    if (desktop == (unsigned long)-1 && g.ewmh.minus1_desktop_unusable)
         return 0;
     msg(1, "ewmh switching desktop to %ld\n", desktop);
     evr = ewmh_send_wm_evt(root, "_NET_CURRENT_DESKTOP", edata);
--- a/src/gui.c
+++ b/src/gui.c
@@ -367,7 +367,7 @@
         if (g.color[p].name[0]) {
             if (strncmp(g.color[p].name, "_rnd_", 5) == 0) {
                 // replace in-place: 8 chars is sufficient for #rrggbb
-                char r[3];
+                unsigned char r[3];
                 short int rc;
                 for (rc = 0; rc <= 2; rc++) {
                     r[rc] = rand() / (RAND_MAX / 0x80);
--- a/src/util.c
+++ b/src/util.c
@@ -101,7 +101,7 @@
         }
         if (grab) {
             if (debug > 1) {
-                fprintf(stderr, "grabbing %d with mask %d\n",
+                fprintf(stderr, "grabbing %d with mask %u\n",
                         keycode, (modmask | mask));
             }
             ee_ignored = NULL;  // to detect X error event
@@ -115,7 +115,7 @@
             }
         } else {
             if (debug > 1) {
-                fprintf(stderr, "ungrabbing %d with mask %d\n",
+                fprintf(stderr, "ungrabbing %d with mask %u\n",
                         keycode, (modmask | mask));
             }
             XUngrabKey(dpy, keycode, modmask | mask, win);
@@ -452,7 +452,7 @@
         XftTextExtentsUtf8(dpy, font, (unsigned char *)line, line_clen, &ext);
         if (debug > 0) {
             fprintf(stderr,
-                    "first cut approximation: \"%s\" ulen=%zu clen=%zu width=%d px, x2-x1=%d px\n",
+                    "first cut approximation: \"%s\" ulen=%zu clen=%zu width=%d px, x2-x1=%u px\n",
                     line, line_ulen, line_clen, ext.width, width);
         }
         while (ext.width > width) {
@@ -466,7 +466,7 @@
                                line_clen, &ext);
             if (debug > 0) {
                 fprintf(stderr,
-                        "cut correction: \"%s\" ulen=%zu clen=%zu width=%d px, x2-x1=%d px\n",
+                        "cut correction: \"%s\" ulen=%zu clen=%zu width=%d px, x2-x1=%u px\n",
                         line, line_ulen, line_clen, ext.width, width);
             }
         }
@@ -474,7 +474,7 @@
         if ((y + ext.height) > (y1 + height)) {
             if (debug > 0) {
                 fprintf(stderr,
-                        "y+ext.height=%d, y2=%d - breaking\n",
+                        "y+ext.height=%d, y2=%u - breaking\n",
                         y + ext.height, (y1 + height));
             }
             break;