From: Changqing Li <changqing.li@windriver.com>
To: Adrian Bunk <bunk@stusta.de>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] cogl: fix compile error with -Werror=maybe-uninitialized
Date: Wed, 3 Apr 2019 10:29:08 +0800 [thread overview]
Message-ID: <3381bfd6-b3ed-da15-69dc-394fc1a9643b@windriver.com> (raw)
In-Reply-To: <20190402113135.GA27866@localhost>
On 4/2/19 7:31 PM, Adrian Bunk wrote:
> On Tue, Apr 02, 2019 at 05:08:33PM +0800, changqing.li@windriver.com wrote:
>> From: Changqing Li <changqing.li@windriver.com>
>>
>> fix below compile error with -Werror=maybe-uninitialized
>>
>> | ../../cogl-1.22.2/cogl/driver/gl/gles/cogl-driver-gles.c:217:17: error: 'gltype' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>> | *out_gltype = gltype;
>> | ~~~~~~~~~~~~^~~~~~~~
>> | ../../cogl-1.22.2/cogl/driver/gl/gles/cogl-driver-gles.c:213:22: error: 'glintformat' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>> | *out_glintformat = glintformat;
>> | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
>> ...
> Looking at the code, is this a failure that only happens with DEBUG_FLAGS?
Yes, only happen with DEBUG_FLAGS
>
>> +--- a/cogl/driver/gl/gles/cogl-driver-gles.c
>> ++++ b/cogl/driver/gl/gles/cogl-driver-gles.c
>> +@@ -74,9 +74,9 @@ _cogl_driver_pixel_format_to_gl (CoglContext *context,
>> + GLenum *out_gltype)
>> + {
>> + CoglPixelFormat required_format;
>> +- GLenum glintformat;
>> ++ GLenum glintformat = 0;
>> + GLenum glformat = 0;
>> +- GLenum gltype;
>> ++ GLenum gltype = 0;
>> ...
> Assigning random values to variables is a bug,
> they do not even seem to be valid values for these variables.
According to code logic, glformat and glintformat will assigned
simultaneously and usually with same value,
and 0 mean invalid pixel format.
[snip]
case COGL_PIXEL_FORMAT_DEPTH_24_STENCIL_8:
glintformat = GL_DEPTH_STENCIL;
glformat = GL_DEPTH_STENCIL;
gltype = GL_UNSIGNED_INT_24_8;
break;
and for gtype, there also should be no problem according to the code logic.
and the fix is just for eliminate the error when DEBUG_FLAGS is enabled.
>
> cu
> Adrian
>
--
BRs
Sandy(Li Changqing)
next prev parent reply other threads:[~2019-04-03 2:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 9:08 [PATCH] cogl: fix compile error with -Werror=maybe-uninitialized changqing.li
2019-04-02 11:31 ` Adrian Bunk
2019-04-03 2:29 ` Changqing Li [this message]
2019-04-03 9:58 ` Adrian Bunk
2019-04-04 2:06 ` Changqing Li
2019-04-04 8:11 ` Adrian Bunk
2019-04-08 2:12 ` Changqing Li
2019-04-04 13:42 ` Burton, Ross
2019-04-08 2:14 ` Changqing Li
2019-04-08 6:01 ` [PATCH V2] " changqing.li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3381bfd6-b3ed-da15-69dc-394fc1a9643b@windriver.com \
--to=changqing.li@windriver.com \
--cc=bunk@stusta.de \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.