Skip to content

comparing a return value of c_inet_addr with a positive number. - #261

Merged
kazu-yamamoto merged 1 commit into
masterfrom
inet_addr
Dec 12, 2017
Merged

kazu-yamamoto merged 1 commit into
masterfrom
inet_addr

Conversation

@kazu-yamamoto

Copy link
Copy Markdown
Collaborator

c_inet_addr returns a value of Word32.
So, we cannot compare it with (-1).
GHC 8.2 detects this bug.

@eborden eborden left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vincenthz

vincenthz commented Dec 11, 2017 •

Copy link
Copy Markdown

it's a bit sad this is raising a warning in this case (it's really not overflowing), but I would suggest fixing the warning not by hardcoding -1's representation but instead using either:

+   if had == maxBound
+   if had == -(1)

The later -(1) trick shows how the warning is not consistent between the literal definition and haskell definition of negate/unary minus.

@kazu-yamamoto
kazu-yamamoto merged commit dcd08cc into master Dec 12, 2017
kazu-yamamoto added a commit that referenced this pull request Dec 12, 2017
@kazu-yamamoto
kazu-yamamoto deleted the inet_addr branch December 12, 2017 00:53
@kazu-yamamoto

Copy link
Copy Markdown
Collaborator Author

@vincenthz Thank you for your suggestion. I took maxBound.

@eborden Than you for your review. I have modified, rebased and merged the commit.

I'm now trying to make history linear. So, I did push -f to this PR. And I will continue this procedure from now on since a linear history is really nice.

kazu-yamamoto added a commit to kazu-yamamoto/network that referenced this pull request Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants