GNOME Bugzilla – Bug 751985
rtph261pay: Fix uninitialized variable compiler error
Last modified: 2015-08-16 13:41:11 UTC
when we do compile rtph261pay using jhbuild, compiler error appears. Here is the error message. gstrtph261pay.c: In function 'gst_rtp_h261_packetize_and_push': gstrtph261pay.c:661:34: error: 'endpos' may be used uninitialized in this function [-Werror=uninitialized] gstrtph261pay.c:854:11: note: 'endpos' was declared here I want to know that compile option are changed or not in the latest version.
Created attachment 306859 [details] [review] Fix uninitialized variable compiler error
Created attachment 306863 [details] [review] Patch to fix compiler warning The previously proposed patch also removes a useful debug message. This patch should fix the warning while keeping the debug message. This seems to be an issue with GCC not correctly understanding that the particular branch cannot be entered on the first iteration of the loop (because of the 'count' variable). Although I don't get the same warning with GCC 4.8.4 the provided patch should fix the issue. @Jimmy: This code was recently added so the warning you get is not due to changed compiler flags.
@Jimmy: Could you confirm that fixes your warning (and please also tell us the exact compiler + version you're using, 'latest compiler' is not very precise).
@Tim and @Stian Here is the my GCC version. sorry about that. It's not latest compiler version. :( -> gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Also, I test proposed patch from Stian in my desktop. but it's same compiler error. Actually, I already try endpos initialization like proposed patch from Stian before attach my patch. I agree Stian comment. maybe gcc compiler does not correctly understand that code in 4.6.3 GCC version.
Created attachment 306899 [details] [review] Patch to fix compiler warning This patch is basically the same as Jimmy's but keeps a modified version of the debug message in addition. @Jimmy: Can you please verify that the fix still works for you after I added the debug message? Btw, I was not able to reproduce with either 4.6.4 or 4.6.3. Could be some environment differences.
@Stian It's working for me in my GCC 4.6.3 version. How about attached my new patch? This patch is keep the original debug message.
Created attachment 306903 [details] [review] rtph261pay: Fix uninitialized variable compiler error
Thanks, Jimmy. Even better would be to just move "Macroblock mb;" outside the loop instead of declaring a new Macroblock in order to avoid copying the struct. If you do that I would say the patch looks good.
Created attachment 306967 [details] [review] Fix compiler error about uninitialized variable This patch is to fix compile error in GCC 4.6.3 version. @Stian Thanks for your comment. I upload new patch included your comment.
LGTM
commit 19e7f188fa0e6fca73f8f080c315d4bbd99f708f Author: Tim-Philipp Müller <tim@centricular.com> Date: Tue Jul 7 09:18:39 2015 +0100 rtph261pay: fix indentation commit 2f016f3f9dd4c3bbf5f5de24ab2e866466bb7a3b Author: Jimmy Ohn <yongjin.ohn@lge.com> Date: Mon Jul 6 19:11:00 2015 +0900 rtph261pay: Fix uninitialized variable compiler error endpos variable does not correctly understand in the 4.6.3 GCC version. So compile error appears when we do compile rtph261pay using jhbuild. This patch is fixed the compile error in 4.6.3 GCC version. https://bugzilla.gnome.org/show_bug.cgi?id=751985
Comment on attachment 306967 [details] [review] Fix compiler error about uninitialized variable >+ if(ret == PARSE_OK) { This does not follow GStreamer indentation, make sure you have GNU indent installed, it should complain when you try to git commit locally.