summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-12 15:14:23 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-12 16:25:35 +0900
commit8c70210ee6cf4c04f8a61ad27bbf216436659d34 (patch)
treec226604cf0a819ea22703ca7523b8442fb739e02
parentb40fd20fbc5c5cc05f514929eddc1d4c08b93636 (diff)
e xsettings - fix warnings about unaligned ptr access
this moves access to byte by byte memcpy's to avoid potential unaligned access.
-rw-r--r--src/bin/e_xsettings.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/bin/e_xsettings.c b/src/bin/e_xsettings.c
index 74d5413c4..b26654bac 100644
--- a/src/bin/e_xsettings.c
+++ b/src/bin/e_xsettings.c
@@ -273,13 +273,16 @@ _e_xsettings_copy(unsigned char *buffer, Setting *s)
273{ 273{
274 size_t str_len; 274 size_t str_len;
275 size_t len; 275 size_t len;
276 C16 tmp16;
277 C32 tmp32;
276 278
277 buffer[0] = s->type; 279 buffer[0] = s->type;
278 buffer[1] = 0; 280 buffer[1] = 0;
279 buffer += 2; 281 buffer += 2;
280 282
281 str_len = strlen(s->name); 283 str_len = strlen(s->name);
282 *(C16 *)(buffer) = str_len; 284 tmp16 = str_len;
285 memcpy(buffer, &tmp16, sizeof(C16));
283 buffer += 2; 286 buffer += 2;
284 287
285 memcpy(buffer, s->name, str_len); 288 memcpy(buffer, s->name, str_len);
@@ -289,19 +292,22 @@ _e_xsettings_copy(unsigned char *buffer, Setting *s)
289 memset(buffer, 0, len); 292 memset(buffer, 0, len);
290 buffer += len; 293 buffer += len;
291 294
292 *(C32 *)(buffer) = s->last_change; 295 tmp32 = s->last_change;
296 memcpy(buffer, &tmp32, sizeof(C32));
293 buffer += 4; 297 buffer += 4;
294 298
295 switch (s->type) 299 switch (s->type)
296 { 300 {
297 case SETTING_TYPE_INT: 301 case SETTING_TYPE_INT:
298 *(C32 *)(buffer) = s->i.value; 302 tmp32 = s->i.value;
303 memcpy(buffer, &tmp32, sizeof(C32));
299 buffer += 4; 304 buffer += 4;
300 break; 305 break;
301 306
302 case SETTING_TYPE_STRING: 307 case SETTING_TYPE_STRING:
303 str_len = strlen(s->s.value); 308 str_len = strlen(s->s.value);
304 *(C32 *)(buffer) = str_len; 309 tmp32 = str_len;
310 memcpy(buffer, &tmp32, sizeof(C32));
305 buffer += 4; 311 buffer += 4;
306 312
307 memcpy(buffer, s->s.value, str_len); 313 memcpy(buffer, s->s.value, str_len);
@@ -313,11 +319,18 @@ _e_xsettings_copy(unsigned char *buffer, Setting *s)
313 break; 319 break;
314 320
315 case SETTING_TYPE_COLOR: 321 case SETTING_TYPE_COLOR:
316 *(C16 *)(buffer) = s->c.red; 322 tmp16 = s->c.red;
317 *(C16 *)(buffer + 2) = s->c.green; 323 memcpy(buffer, &tmp16, sizeof(C16));
318 *(C16 *)(buffer + 4) = s->c.blue; 324 buffer += 2;
319 *(C16 *)(buffer + 6) = s->c.alpha; 325 tmp16 = s->c.green;
320 buffer += 8; 326 memcpy(buffer, &tmp16, sizeof(C16));
327 buffer += 2;
328 tmp16 = s->c.blue;
329 memcpy(buffer, &tmp16, sizeof(C16));
330 buffer += 2;
331 tmp16 = s->c.alpha;
332 memcpy(buffer, &tmp16, sizeof(C16));
333 buffer += 2;
321 break; 334 break;
322 } 335 }
323 336
@@ -332,6 +345,7 @@ _e_xsettings_apply(Settings_Manager *sm)
332 size_t len = 12; 345 size_t len = 12;
333 Setting *s; 346 Setting *s;
334 Eina_List *l; 347 Eina_List *l;
348 C32 tmp32;
335 349
336 EINA_LIST_FOREACH(settings, l, s) 350 EINA_LIST_FOREACH(settings, l, s)
337 len += s->length; 351 len += s->length;
@@ -346,9 +360,11 @@ _e_xsettings_apply(Settings_Manager *sm)
346#endif 360#endif
347 361
348 pos += 4; 362 pos += 4;
349 *(C32 *)pos = sm->serial++; 363 tmp32 = sm->serial++;
364 memcpy(pos, &tmp32, sizeof(C32));
350 pos += 4; 365 pos += 4;
351 *(C32 *)pos = eina_list_count(settings); 366 tmp32 = eina_list_count(settings);
367 memcpy(pos, &tmp32, sizeof(C32));
352 pos += 4; 368 pos += 4;
353 369
354 EINA_LIST_FOREACH(settings, l, s) 370 EINA_LIST_FOREACH(settings, l, s)