Let's keep compilers and static analyzers happy. The idea is to use
memcpy() to copy from buffer to variable and use all label as unsigned
char rather than vectorize by uint32_t.
Signed-off-by: Karel Zak <kzak@redhat.com>
static inline uint32_t sgi_pt_checksum(struct sgi_disklabel *label)
{
- int i;
- uint32_t *ptr = (uint32_t *) label;
+ int count;
uint32_t sum = 0;
+ unsigned char *ptr = (unsigned char *) label;
- i = sizeof(*label) / sizeof(*ptr);
+ count = sizeof(*label) / sizeof(uint32_t);
+ ptr += sizeof(uint32_t) * (count - 1);
- while (i) {
- i--;
- sum -= be32_to_cpu(ptr[i]);
+ while (count--) {
+ uint32_t val;
+
+ memcpy(&val, ptr, sizeof(uint32_t));
+ sum -= be32_to_cpu(val);
+
+ ptr -= sizeof(uint32_t);
}
return sum;