~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to colormaps.c

  • Committer: Matthew Fuller
  • Date: 2021-07-13 23:27:31 UTC
  • mto: This revision was merged to the branch mainline in revision 689.
  • Revision ID: fullermd@over-yonder.net-20210713232731-pmm7yuqltn2ip0vj
Work around spurious-ish gcc11 warning.

XSaveContext() is basically just stashing up the pointer for later
XFindContext() calls to retrieve, so it doesn't matter what's in it
(or indeed if it's even a valid pointer, at least 'till we deref it
after XFC()).  But gcc11 doesn't know that, so it gets grumpy about
passing an uninitialized blob in.  Easy enough workaround; just do our
setup before stashing it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
247
247
{
248
248
        TwmColormap *cmap;
249
249
        cmap = malloc(sizeof(TwmColormap));
250
 
        if(!cmap || XSaveContext(dpy, c, ColormapContext, (XPointer) cmap)) {
251
 
                if(cmap) {
252
 
                        free(cmap);
253
 
                }
254
 
                return (NULL);
 
250
        if(!cmap) {
 
251
                return NULL;
255
252
        }
256
253
        cmap->c = c;
257
254
        cmap->state = 0;
258
255
        cmap->install_req = 0;
259
256
        cmap->w = None;
260
257
        cmap->refcnt = 1;
 
258
 
 
259
        if(XSaveContext(dpy, c, ColormapContext, (XPointer) cmap)) {
 
260
                free(cmap);
 
261
                return NULL;
 
262
        }
261
263
        return (cmap);
262
264
}
263
265