After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 730378 - addressbook: Strengthen an assertion to avoid negative bit shifts
addressbook: Strengthen an assertion to avoid negative bit shifts
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Evolution Shell Maintainers Team
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2014-05-19 13:52 UTC by Philip Withnall
Modified: 2014-11-03 22:19 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
addressbook: Strengthen an assertion to avoid negative bit shifts (1.16 KB, patch)
2014-05-19 13:52 UTC, Philip Withnall
rejected Details | Review
addressbook: Strengthen an assertion to avoid negative bit shifts (1.17 KB, patch)
2014-05-20 10:33 UTC, Philip Withnall
committed Details | Review
addressbook: Strengthen an assertion to avoid negative bit shifts (1.05 KB, patch)
2014-11-01 14:11 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2014-05-19 13:52:12 UTC
Patch attached.
Comment 1 Philip Withnall 2014-05-19 13:52:15 UTC
Created attachment 276777 [details] [review]
addressbook: Strengthen an assertion to avoid negative bit shifts

This should never happen in practice, but it is good to be completely
explicit in the assertion.

Coverity issue: #1214485
Comment 2 Milan Crha 2014-05-19 16:34:12 UTC
Review of attachment 276777 [details] [review]:

As mentioned elsewhere, do not use g_assert().
Comment 3 Philip Withnall 2014-05-20 10:33:56 UTC
Created attachment 276837 [details] [review]
addressbook: Strengthen an assertion to avoid negative bit shifts

This should never happen in practice, but it is good to be completely
explicit in the assertion.

Coverity issue: #1214485
Comment 4 Milan Crha 2014-05-21 12:08:30 UTC
Review of attachment 276837 [details] [review]:

Looks good, please commit. Thanks.
Comment 5 Philip Withnall 2014-05-21 12:46:07 UTC
Attachment 276837 [details] pushed as 5accb2b - addressbook: Strengthen an assertion to avoid negative bit shifts
Comment 6 Philip Withnall 2014-11-01 14:11:03 UTC
Created attachment 289781 [details] [review]
addressbook: Strengthen an assertion to avoid negative bit shifts

This should never happen in practice, but it is good to be completely
explicit in the assertion.

Follow up to commit 10d55d18.

Coverity issue: #1250458
Comment 7 Philip Withnall 2014-11-01 14:12:03 UTC
Another instance of it popped up in Coverity. Patch attached.
Comment 8 Milan Crha 2014-11-03 10:25:35 UTC
Review of attachment 289781 [details] [review]:

It only prints a warning and then calls the below code anyway. Are you sure it's sufficient for Coverity to not identify the code as faulty?
Comment 9 Philip Withnall 2014-11-03 16:04:02 UTC
(In reply to comment #8)
> It only prints a warning and then calls the below code anyway. Are you sure
> it's sufficient for Coverity to not identify the code as faulty?

IIRC, when I originally posted these patches, I used g_assert(), but then (as per comment #2), you wanted g_warn_if_fail() instead. That seems to be OK for Coverity, but I’m not sure why. In any case, it documents the intent better.

I think your reasoning for preferring g_warn_if_fail() over g_assert() was to stop the daemon exploding on a problem, and let it stumble on instead (because the undefined behaviour in this case is probably fine). If you want to use g_assert() instead, I would be more than happy to. :-)
Comment 10 Milan Crha 2014-11-03 18:20:45 UTC
Heh, I'm still not in favour of g_assert(), it surprised me that Coverity is fine with something what actually doesn't prevent the problem. If your tests shows that Coverity is fine with it, then feel free to commit to sources as it is. Thanks.
Comment 11 Philip Withnall 2014-11-03 22:17:54 UTC
(In reply to comment #10)
> Heh, I'm still not in favour of g_assert(), it surprised me that Coverity is
> fine with something what actually doesn't prevent the problem. If your tests
> shows that Coverity is fine with it, then feel free to commit to sources as it
> is. Thanks.

Well, even if it turns out that Coverity isn’t fine with it, having the g_warn_if_fail() there makes it obvious that the error in Coverity is a false positive, and can safely be marked as ignored.
Comment 12 Philip Withnall 2014-11-03 22:19:15 UTC
Attachment 289781 [details] pushed as 51e9e69 - addressbook: Strengthen an assertion to avoid negative bit shifts