Merge lp:~stefan.goetz-deactivatedaccount/hipl/unittests into lp:hipl

Proposed by Stefan Götz
Status: Merged
Merged at revision: 5095
Proposed branch: lp:~stefan.goetz-deactivatedaccount/hipl/unittests
Merge into: lp:hipl
Diff against target: 44 lines (+15/-10)
1 file modified
test/lib/core/hit.c (+15/-10)
To merge this branch: bzr merge lp:~stefan.goetz-deactivatedaccount/hipl/unittests
Reviewer Review Type Date Requested Status
HIPL core team Pending
Review via email: mp+39225@code.launchpad.net

Description of the change

Bug fix for compiler error at -O0

To post a comment you must log in.
5011. By Stefan Götz

Pulled lp:hipl trunk to avoid conflicts against trunk.

5012. By Stefan Götz

Removed unnecessary cast and dereference from unit test.

Revision history for this message
Stefan Götz (stefan.goetz-deactivatedaccount) wrote :

On 10/24/2010 07:30 PM, René Hummen wrote:
>> // write the HIT string into the middle of the buffer
>> - fail_unless(hip_convert_hit_to_str(&hit, suffix, buf + BEFORE_LEN) == 0, NULL);
>> + fail_unless(hip_convert_hit_to_str(&hit, suffix, (char *)&buf.hit) == 0, NULL);
>
> buf.hit is already a pointer to the char[]. There's no need to cast and to use it's address.

Fixed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/lib/core/hit.c'
2--- test/lib/core/hit.c 2010-10-19 12:01:36 +0000
3+++ test/lib/core/hit.c 2010-10-24 21:02:04 +0000
4@@ -70,26 +70,31 @@
5 const unsigned int HIT_LEN = 39; // 16 bytes -> 32 hex chars + 7 ':'s
6 const unsigned int SUFFIX_LEN = sizeof(suffix); // includes null char
7 const unsigned int AFTER_LEN = 30;
8- char buf[BEFORE_LEN + HIT_LEN + SUFFIX_LEN + AFTER_LEN];
9- char ones[BEFORE_LEN + HIT_LEN + SUFFIX_LEN + AFTER_LEN];
10+ struct {
11+ char before[BEFORE_LEN];
12+ char hit[HIT_LEN];
13+ char suffix[SUFFIX_LEN];
14+ char after[AFTER_LEN];
15+ } buf;
16+ char ones[sizeof(buf)];
17 hip_hit_t hit;
18
19- memset(buf, '1', sizeof(buf));
20- memset(ones, '1', sizeof(ones));
21+ memset(&buf, 1, sizeof(buf));
22+ memset(ones, 1, sizeof(ones));
23 memset(&hit.s6_addr, 0x22, sizeof(hit.s6_addr));
24
25 // write the HIT string into the middle of the buffer
26- fail_unless(hip_convert_hit_to_str(&hit, suffix, buf + BEFORE_LEN) == 0, NULL);
27+ fail_unless(hip_convert_hit_to_str(&hit, suffix, buf.hit) == 0, NULL);
28 // is the buffer before the HIT untouched?
29- fail_unless(memcmp(buf, ones, BEFORE_LEN) == 0, NULL);
30+ fail_unless(memcmp(&buf.before, ones, BEFORE_LEN) == 0, NULL);
31 // is the first part of the HIT correct?
32- fail_unless(*(buf + BEFORE_LEN) == '2', NULL);
33+ fail_unless(buf.hit[0] == '2', NULL);
34 // is the last part of the HIT correct?
35- fail_unless(*(buf + BEFORE_LEN + HIT_LEN - 1) == '2', NULL);
36+ fail_unless(buf.hit[HIT_LEN - 1] == '2', NULL);
37 // is the suffix correct including the terminating null character?
38- fail_unless(memcmp(buf + BEFORE_LEN + HIT_LEN, suffix, SUFFIX_LEN) == 0, NULL);
39+ fail_unless(memcmp(&buf.suffix, suffix, SUFFIX_LEN) == 0, NULL);
40 // is the buffer after the suffix untouched?
41- fail_unless(memcmp(buf + BEFORE_LEN + HIT_LEN + SUFFIX_LEN, ones, AFTER_LEN) == 0, NULL);
42+ fail_unless(memcmp(&buf.after, ones, AFTER_LEN) == 0, NULL);
43 }
44 END_TEST
45

Subscribers

People subscribed via source and target branches

to all changes: