-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixed -Wmissing-prototypes
(and subsequent) compiler warnings
#2829
Conversation
I can still squash this if desired. |
On a side note: IMO the variable prefix |
Hi again. I'd like to reproduce this got the purposes of reviewing the PR. How are you causing clang to generate the errors? It would be good to get any additional error checking into the CI process if possible. |
I added If you want to integrate this properly and portable you need to add a check to the autoconf process as not all compilers provide this warning. Unfortunately I have never worked with that and have no idea how to add such a check. It is probably just a one liner as this is something common. |
Are you aware of any compilers that don't support it? I've just checked gcc 4.8.5 on CentOS 7 and that has the flag. Here's a patch for you which makes the check in any case:- diff --git a/configure.ac b/configure.ac
index 2f3d6938..e677ea46 100644
--- a/configure.ac
+++ b/configure.ac
@@ -205,6 +205,9 @@ AX_GCC_FUNC_ATTRIBUTE([format])
AX_TYPE_SOCKLEN_T
AX_CFLAGS_WARN_ALL
AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
+AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes],
+ [AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes])],
+ , [-Werror])
AM_COND_IF([LINUX],
[AX_APPEND_COMPILE_FLAGS([-Werror])]) # bsd has warnings that have not been fixed yet |
I've just pushed a branch with that patch in and no other changes. Failing CI results are here:- |
I will separate the changes into separate commits for the various warnings (the initial commit mixed together at least three different warnings) so it is better to follow. I would add your change in a separate PR and clean up the |
|
It was even on the previous line in the config and I missed it - Good spot! I'd suggest the following then:- --- a/configure.ac
+++ b/configure.ac
@@ -205,6 +205,7 @@ AX_GCC_FUNC_ATTRIBUTE([format])
AX_TYPE_SOCKLEN_T
AX_CFLAGS_WARN_ALL
AX_APPEND_COMPILE_FLAGS([-Wwrite-strings])
+AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes], ,[-Werror])
AM_COND_IF([LINUX],
[AX_APPEND_COMPILE_FLAGS([-Werror])]) # bsd has warnings that have not been fixed yet The [-Werror] is needed as otherwise some compilers (particularly clang) may emit a warning rather than an error. See:- |
49e5cec
to
926cadc
Compare
I was wondering about that but I omitted it anyways. Will adjust. |
926cadc
to
d66fffe
Compare
I am not 100% sure if the removal of the function is safe as those might be used when the code is in a shared object. But as |
-Wmissing-prototypes
Clang compiler warnings-Wmissing-prototypes
(and related) compiler warnings
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Largely happy with this. Just one comment.
configure.ac
Outdated
@@ -205,6 +205,8 @@ AX_GCC_FUNC_ATTRIBUTE([format]) | |||
AX_TYPE_SOCKLEN_T | |||
AX_CFLAGS_WARN_ALL | |||
AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) | |||
AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes], ,[-Werror]) | |||
AX_APPEND_COMPILE_FLAGS([-Wno-error=missing-prototypes], ,[-Werror]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't understand the 2nd line here. What is this doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That tells the compiler not to treat that warning as an error as I still haven't fixed all of them. As it is just two functions I might still do it in this PR.
BTW that is also like the remaining compiler warnings on BSD should be handled a few lines below to make sure none of a different type are being introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's being removed later, I'm fine with that - thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. Any such things are (hopefully) temporary. Such things are always fidgety if you apply them to a "legacy" code base.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines can be removed now I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still required until the latest libpainter
and librfxcodec
are being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those changes have been merged.
You can add a commit to your PR which pulls in the latest versions:-
cd libpainter
git checkout devel
git pull
cd ../librfxcodec
git checkout devel
git pull
cd ..
git add libpainter librfxcodec
git commit -m "Update submodules for -Wmissing-prototypes"
Or something like that. You get the idea.
BTW the pixman files are an oddity. My understanding is they're copied from an old version of the pixman library and used if for some reason the user chooses the |
Which appears to be the default otherwise those warnings would have not shown up in my local or the CI builds. Or the files are not excluded from the build if they are not actually used. |
Yes you're right - disable is the default. Most if not all distros use |
Maybe the next release could switch that around so that the code could even be deprecated. Feels kinda weird that a self-spun version differs from most of the otherwise available ones by default. |
d66fffe
to
4ab82c8
Compare
-Wmissing-prototypes
(and related) compiler warnings-Wmissing-prototypes
(and related) compiler warnings
4ab82c8
to
fc86aac
Compare
-Wmissing-prototypes
(and related) compiler warnings-Wmissing-prototypes
(and subsequent) compiler warnings
6c5d095
to
ac28738
Compare
See neutrinolabs/libpainter#21 and neutrinolabs/librfxcodec#59 for upstream fixes. |
9403afe
to
058a015
Compare
--- a/xrdp/Makefile.am
+++ b/xrdp/Makefile.am
@@ -56,6 +56,7 @@ xrdp_SOURCES = \
xrdp_listen.c \
xrdp_login_wnd.c \
xrdp_mm.c \
+ xrdp_mm.h \
xrdp_painter.c \
xrdp_process.c \
xrdp_region.c \ |
058a015
to
9c04a67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this @firewave. Two in-line comments below and one general one here:-
Build also fails with --enable-neutrinordp
option. To get this option to work you'll need to build NeutrinoRDP:-
https://github.com/neutrinolabs/xrdp/wiki/NeutrinoRDP-proxy-module-for-xrdp
Gimme a shout if you need a hand with that.
configure.ac
Outdated
@@ -205,6 +205,8 @@ AX_GCC_FUNC_ATTRIBUTE([format]) | |||
AX_TYPE_SOCKLEN_T | |||
AX_CFLAGS_WARN_ALL | |||
AX_APPEND_COMPILE_FLAGS([-Wwrite-strings]) | |||
AX_APPEND_COMPILE_FLAGS([-Wmissing-prototypes], ,[-Werror]) | |||
AX_APPEND_COMPILE_FLAGS([-Wno-error=missing-prototypes], ,[-Werror]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines can be removed now I think.
|
||
PIXMAN_EXPORT pixman_bool_t | ||
PREFIX (_selfcheck) (region_type_t *reg) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is used if building with --enable-devel-logging
or --eanable-devel-all
(and without --enable-pixman
). Building with these options now gives me a link error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought I did a full tree search for all function before removing them. Must have been my recent sloppiness. Will add back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like I already addressed this.
9c04a67
to
8f068b5
Compare
I finally figured out how to update the submodules so finally here is a rebase. |
8f068b5
to
7b94704
Compare
I think I have addressed everything noted except for the following.
|
|
Sorry - that appears to be a drop-off on my part. #3042 is running through CI at the moment. Assuming it's successful I'll merge it, and then if you rebase we should be OK. Also, here's a patch for neutrinordp. I've also attached it below as a file if you just want to apply it. diff --git a/neutrinordp/xrdp-color.c b/neutrinordp/xrdp-color.c
index b0f94c7c..b93bebb3 100644
--- a/neutrinordp/xrdp-color.c
+++ b/neutrinordp/xrdp-color.c
@@ -27,6 +27,8 @@
#include "os_calls.h"
#include "string_calls.h"
+#include "xrdp-color.h"
+
char *
convert_bitmap(int in_bpp, int out_bpp, char *bmpdata,
int width, int height, int *palette)
diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c
index 6574c3fa..b33bd042 100644
--- a/neutrinordp/xrdp-neutrinordp.c
+++ b/neutrinordp/xrdp-neutrinordp.c
@@ -2041,7 +2041,7 @@ lfreerdp_pre_connect(freerdp *instance)
}
/*****************************************************************************/
-void
+static void
lrail_WindowCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
WINDOW_STATE_ORDER *window_state)
{
@@ -2122,7 +2122,7 @@ lrail_WindowCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
}
/*****************************************************************************/
-void
+static void
lrail_WindowUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
WINDOW_STATE_ORDER *window_state)
{
@@ -2131,7 +2131,7 @@ lrail_WindowUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
}
/*****************************************************************************/
-void
+static void
lrail_WindowDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo)
{
struct mod *mod;
@@ -2142,7 +2142,7 @@ lrail_WindowDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo)
}
/*****************************************************************************/
-void
+static void
lrail_WindowIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
WINDOW_ICON_ORDER *window_icon)
{
@@ -2168,7 +2168,7 @@ lrail_WindowIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
}
/*****************************************************************************/
-void
+static void
lrail_WindowCachedIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
WINDOW_CACHED_ICON_ORDER *window_cached_icon)
{
@@ -2183,7 +2183,7 @@ lrail_WindowCachedIcon(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
}
/*****************************************************************************/
-void
+static void
lrail_NotifyIconCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
NOTIFY_ICON_STATE_ORDER *notify_icon_state)
{
@@ -2240,7 +2240,7 @@ lrail_NotifyIconCreate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
}
/*****************************************************************************/
-void
+static void
lrail_NotifyIconUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
NOTIFY_ICON_STATE_ORDER *notify_icon_state)
{
@@ -2249,7 +2249,7 @@ lrail_NotifyIconUpdate(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
}
/*****************************************************************************/
-void
+static void
lrail_NotifyIconDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo)
{
struct mod *mod;
@@ -2261,7 +2261,7 @@ lrail_NotifyIconDelete(rdpContext *context, WINDOW_ORDER_INFO *orderInfo)
}
/*****************************************************************************/
-void
+static void
lrail_MonitoredDesktop(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
MONITORED_DESKTOP_ORDER *monitored_desktop)
{
@@ -2293,7 +2293,7 @@ lrail_MonitoredDesktop(rdpContext *context, WINDOW_ORDER_INFO *orderInfo,
}
/*****************************************************************************/
-void
+static void
lrail_NonMonitoredDesktop(rdpContext *context, WINDOW_ORDER_INFO *orderInfo)
{
struct mod *mod; |
#3042 is now merged. |
Co-authored-by: matt335672 <[email protected]>
vnc.c: In function ‘lib_framebuffer_update’: vnc.c:816:37: error: ‘b’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 816 | return (r << 16) | (g << 8) | b; | ~~~~~~~~~~~~~~~~~~~~~^~~ vnc.c:1301:9: note: ‘b’ was declared here 1301 | int b; | ^ vnc.c:816:31: error: ‘g’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 816 | return (r << 16) | (g << 8) | b; | ~~~^~~~~ vnc.c:1300:9: note: ‘g’ was declared here 1300 | int g; | ^ vnc.c:816:19: error: ‘r’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 816 | return (r << 16) | (g << 8) | b; | ~~~^~~~~~ vnc.c:1299:9: note: ‘r’ was declared here 1299 | int r; | ^
7b94704
to
5eed76f
Compare
Co-authored-by: matt335672 <[email protected]>
Great.
Thanks a lot! I integrated it. |
Somehow the dependency installation is extremely slow. But it also looks like GitHub is not properly refreshing so it might be a general issue. |
The runners aren't updating properly at all at the moment. I'm happy to merge this now, but I'll wait until the inevitable checks are likely to succeed. |
Ref the CI problems:- |
Thanks for your contribution @firewave |
You're welcome. I hope the next one is going smoother. |
Fixing this warning mainly involved adding
static
identifiers orvoid
parameters to the declaration or adding missing includes which contained the prototypes. This allowed the compiler to detect unused functions (mainly incommon/pixman-region.c
) and perform improved valueflow (detecting potentially uninitialized variables).Some warnings remain which require the removal of
extern
declarations and usage of the proper headers with the respective prototypes instead.