Bug 102061 - [EFL] Fix build warning in NetworkStateNotifierEfl.cpp
Summary: [EFL] Fix build warning in NetworkStateNotifierEfl.cpp
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit EFL (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: KyungTae Kim
URL:
Keywords:
Depends on:
Blocks: 101761
  Show dependency treegraph
 
Reported: 2012-11-13 02:01 PST by KyungTae Kim
Modified: 2012-11-13 22:12 PST (History)
4 users (show)

See Also:


Attachments
Patch (1.74 KB, patch)
2012-11-13 02:06 PST, KyungTae Kim
no flags Details | Formatted Diff | Diff
Patch (1.81 KB, patch)
2012-11-13 18:32 PST, KyungTae Kim
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description KyungTae Kim 2012-11-13 02:01:47 PST
To fix the below build warning:
 Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp:110:130: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

The second argument for NLMSG_OK need to be unsigned because it is compared with 'unsigned int'.

http://lxr.free-electrons.com/source/include/linux/netlink.h#L86
 41 struct nlmsghdr {
 42         __u32           nlmsg_len;      /* Length of message including header */
 43         __u16           nlmsg_type;     /* Message content */
 44         __u16           nlmsg_flags;    /* Additional flags */
 45         __u32           nlmsg_seq;      /* Sequence number */
 46         __u32           nlmsg_pid;      /* Sending process port ID */
 47 };

 86 #define NLMSG_OK(nlh,len) ((len) >= (int)sizeof(struct nlmsghdr) && \
 87                            (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \
 88                            (nlh)->nlmsg_len <= (len))
Comment 1 KyungTae Kim 2012-11-13 02:06:54 PST
Created attachment 173850 [details]
Patch
Comment 2 Kangil Han 2012-11-13 02:56:43 PST
Comment on attachment 173850 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173850&action=review

> Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp:110
> +        while ((NLMSG_OK(nlh, (unsigned) len)) && (nlh->nlmsg_type != NLMSG_DONE)) {

len is ssize_t type and it includes -1 in its value range.
Why don't you insert some ASSERT stuff before here to make sure '-1' case is managed.
Comment 3 KyungTae Kim 2012-11-13 03:02:44 PST
Comment on attachment 173850 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173850&action=review

>> Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp:110
>> +        while ((NLMSG_OK(nlh, (unsigned) len)) && (nlh->nlmsg_type != NLMSG_DONE)) {
> 
> len is ssize_t type and it includes -1 in its value range.
> Why don't you insert some ASSERT stuff before here to make sure '-1' case is managed.

In here, len always >0 because the outer while check for that.
So, I didn't add additional code to check that for not making redundant code.
Comment 4 Kangil Han 2012-11-13 03:08:03 PST
Comment on attachment 173850 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173850&action=review

>>> Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp:110
>>> +        while ((NLMSG_OK(nlh, (unsigned) len)) && (nlh->nlmsg_type != NLMSG_DONE)) {
>> 
>> len is ssize_t type and it includes -1 in its value range.
>> Why don't you insert some ASSERT stuff before here to make sure '-1' case is managed.
> 
> In here, len always >0 because the outer while check for that.
> So, I didn't add additional code to check that for not making redundant code.

Ah, right!
LGTM, thanks!
Comment 5 Laszlo Gombos 2012-11-13 18:07:39 PST
Comment on attachment 173850 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=173850&action=review

> Source/WebCore/ChangeLog:8
> +        The second argument for NLMSG_OK need to be unsigned for fixing the -Wsign-compare warning.

need -> needs
for fixing --> to avoid

> Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp:110
> +        while ((NLMSG_OK(nlh, (unsigned) len)) && (nlh->nlmsg_type != NLMSG_DONE)) {

static_cast<unsigned>(len)
Comment 6 KyungTae Kim 2012-11-13 18:32:27 PST
Created attachment 174048 [details]
Patch
Comment 7 WebKit Review Bot 2012-11-13 21:24:16 PST
Comment on attachment 174048 [details]
Patch

Clearing flags on attachment: 174048

Committed r134537: <http://trac.webkit.org/changeset/134537>
Comment 8 WebKit Review Bot 2012-11-13 21:24:20 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Chris Dumez 2012-11-13 22:10:25 PST
Comment on attachment 174048 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=174048&action=review

> Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp:110
> +        while ((NLMSG_OK(nlh, static_cast<unsigned>(len))) && (nlh->nlmsg_type != NLMSG_DONE)) {

If I check "man netlink" on my machine, I get:
int NLMSG_OK(struct nlmsghdr *nlh, int len);

It says that the second argument is signed.
Comment 10 Chris Dumez 2012-11-13 22:12:22 PST
(In reply to comment #9)
> (From update of attachment 174048 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=174048&action=review
> 
> > Source/WebCore/platform/network/efl/NetworkStateNotifierEfl.cpp:110
> > +        while ((NLMSG_OK(nlh, static_cast<unsigned>(len))) && (nlh->nlmsg_type != NLMSG_DONE)) {
> 
> If I check "man netlink" on my machine, I get:
> int NLMSG_OK(struct nlmsghdr *nlh, int len);
> 
> It says that the second argument is signed.

Oh, I have just seen your first comment. the "man" page is misleading then. Clearly an issue with that macro but anyways.