[ 
https://issues.apache.org/jira/browse/HADOOP-10810?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Chris Nauroth updated HADOOP-10810:
-----------------------------------

    Attachment: HADOOP-10810.2.patch

Thanks for the review, Colin.  I'm attaching patch v2 with a slight 
modification on the change you suggested.  I used {{sd->pollfd\[i\].fd}}.  (Dot 
instead of arrow needed after the indexing into the array.)  I agree that this 
looks better.

The change in DomainSocketWatcher.c addresses this warning from gcc:

{code}
     [exec] 
/mnt/data/cnauroth/git/hadoop-common/hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/net/unix/DomainSocketWatcher.c:142:20:
 warning: ‘pollfd’ may be used uninitialized in this function [-Wuninitialized]
{code}

The interesting case to consider is if {{used_size}} is 0, because then the 
{{pollfd}} assignment line never executes.  It seems the compiler then doesn't 
think the {{i == used_size}} check is sufficient to give an early exit before 
the later code accesses {{pollfd}}.  It's probably considering the possibility 
that {{used_size}} could have been assigned a negative value.  (That's not 
something that really happens in practice, but the compiler doesn't know that.) 
 To fix this, I switched the logic to something equivalent but more explicit by 
initializing {{pollfd}} to {{NULL}} and then checking for that condition in the 
early exit.

bq. You might want to try clang if you've got that.

That's an interesting idea.  If you don't mind, I'd like to keep this patch 
focused on this set of warnings and leave clang warnings for future 
investigation.

> Clean up native code compilation warnings.
> ------------------------------------------
>
>                 Key: HADOOP-10810
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10810
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: native
>    Affects Versions: 3.0.0, 2.5.0
>            Reporter: Chris Nauroth
>            Assignee: Chris Nauroth
>            Priority: Minor
>         Attachments: HADOOP-10810.1.patch, HADOOP-10810.2.patch
>
>
> There are several compilation warnings coming from the native code on both 
> Linux and Windows.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to