diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2017-06-21 11:27:17 -0400 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2017-07-07 11:25:18 -0400 |
commit | 278b1d709c6acc6f7d138fed775c76695b068e43 (patch) | |
tree | b09bfb75761ff13c956e310834c34e25e34576ba /net/ceph | |
parent | ab75144be08cfc1d80f49e9c37970fcadb1215a2 (diff) |
libceph: ceph_decode_skip_* helpers
Some of these won't be as efficient as they could be (e.g.
ceph_decode_skip_set(... 32 ...) could advance by len * sizeof(u32)
once instead of advancing by sizeof(u32) len times), but that's fine
and not worth a bunch of extra macro code.
Replace skip_name_map() with ceph_decode_skip_map as an example.
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Diffstat (limited to 'net/ceph')
-rw-r--r-- | net/ceph/osdmap.c | 25 |
1 files changed, 3 insertions, 22 deletions
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 423747714017..f6d561edd511 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
@@ -138,21 +138,6 @@ bad: | |||
138 | return -EINVAL; | 138 | return -EINVAL; |
139 | } | 139 | } |
140 | 140 | ||
141 | static int skip_name_map(void **p, void *end) | ||
142 | { | ||
143 | int len; | ||
144 | ceph_decode_32_safe(p, end, len ,bad); | ||
145 | while (len--) { | ||
146 | int strlen; | ||
147 | *p += sizeof(u32); | ||
148 | ceph_decode_32_safe(p, end, strlen, bad); | ||
149 | *p += strlen; | ||
150 | } | ||
151 | return 0; | ||
152 | bad: | ||
153 | return -EINVAL; | ||
154 | } | ||
155 | |||
156 | static void crush_finalize(struct crush_map *c) | 141 | static void crush_finalize(struct crush_map *c) |
157 | { | 142 | { |
158 | __s32 b; | 143 | __s32 b; |
@@ -187,7 +172,6 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
187 | void **p = &pbyval; | 172 | void **p = &pbyval; |
188 | void *start = pbyval; | 173 | void *start = pbyval; |
189 | u32 magic; | 174 | u32 magic; |
190 | u32 num_name_maps; | ||
191 | 175 | ||
192 | dout("crush_decode %p to %p len %d\n", *p, end, (int)(end - *p)); | 176 | dout("crush_decode %p to %p len %d\n", *p, end, (int)(end - *p)); |
193 | 177 | ||
@@ -353,12 +337,9 @@ static struct crush_map *crush_decode(void *pbyval, void *end) | |||
353 | } | 337 | } |
354 | } | 338 | } |
355 | 339 | ||
356 | /* ignore trailing name maps. */ | 340 | ceph_decode_skip_map(p, end, 32, string, bad); /* type_map */ |
357 | for (num_name_maps = 0; num_name_maps < 3; num_name_maps++) { | 341 | ceph_decode_skip_map(p, end, 32, string, bad); /* name_map */ |
358 | err = skip_name_map(p, end); | 342 | ceph_decode_skip_map(p, end, 32, string, bad); /* rule_name_map */ |
359 | if (err < 0) | ||
360 | goto done; | ||
361 | } | ||
362 | 343 | ||
363 | /* tunables */ | 344 | /* tunables */ |
364 | ceph_decode_need(p, end, 3*sizeof(u32), done); | 345 | ceph_decode_need(p, end, 3*sizeof(u32), done); |