summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2019-03-01 10:23:24 -0500
committerMike Blumenkrantz <zmike@samsung.com>2019-03-01 10:23:24 -0500
commit338fb6451ad087e8b2e795c3717be9cb33b36fae (patch)
tree72cea5f07c21a087cbd7f2cd520b2dec922ff41e
parentc8a7a5a77f7e44a7f0ed9d556409f8c233a29f65 (diff)
elementary: fix performance example warning by using Eina_Slstr instead of hardcoded buffer.
Reviewers: zmike Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D8070
-rw-r--r--src/examples/elementary/performance/graphical.c8
-rw-r--r--src/examples/elementary/performance/performance.c103
-rw-r--r--src/examples/elementary/performance/tools_private.h8
3 files changed, 65 insertions, 54 deletions
diff --git a/src/examples/elementary/performance/graphical.c b/src/examples/elementary/performance/graphical.c
index 13d7ea1..3c7caa2 100644
--- a/src/examples/elementary/performance/graphical.c
+++ b/src/examples/elementary/performance/graphical.c
@@ -1,5 +1,9 @@
1#define EFL_EO_API_SUPPORT 1#ifndef EFL_EO_API_SUPPORT
2#define EFL_BETA_API_SUPPORT 2# define EFL_EO_API_SUPPORT
3#endif
4#ifndef EFL_BETA_API_SUPPORT
5# define EFL_BETA_API_SUPPORT
6#endif
3 7
4#include <math.h> 8#include <math.h>
5#include <stdlib.h> 9#include <stdlib.h>
diff --git a/src/examples/elementary/performance/performance.c b/src/examples/elementary/performance/performance.c
index 74c8f84..cced019 100644
--- a/src/examples/elementary/performance/performance.c
+++ b/src/examples/elementary/performance/performance.c
@@ -19,9 +19,6 @@
19 * @endverbatim 19 * @endverbatim
20 */ 20 */
21 21
22#define EFL_EO_API_SUPPORT
23#define EFL_BETA_API_SUPPORT
24
25/*enable automation test*/ 22/*enable automation test*/
26#ifdef ENABLE_ATPORT 23#ifdef ENABLE_ATPORT
27 #include "at_port.h" 24 #include "at_port.h"
@@ -33,6 +30,12 @@
33#include <stdio.h> 30#include <stdio.h>
34#include <stdlib.h> 31#include <stdlib.h>
35 32
33#ifndef EFL_EO_API_SUPPORT
34# define EFL_EO_API_SUPPORT
35#endif
36#ifndef EFL_BETA_API_SUPPORT
37# define EFL_BETA_API_SUPPORT
38#endif
36 39
37#include <Eo.h> 40#include <Eo.h>
38#include <Evas.h> 41#include <Evas.h>
@@ -60,13 +63,11 @@ void _clear_buf(char *buf)
60 buf[i] = '\0'; 63 buf[i] = '\0';
61} 64}
62 65
63void _value_int_to_char(char *buf, int value, const char *description) 66Eina_Slstr * _value_int_to_char(int value, const char *description)
64{ 67{
65 _clear_buf(buf);
66 if (description) 68 if (description)
67 sprintf(buf, "%s %d", description, value); 69 return eina_slstr_printf("%s %d", description, value);
68 else 70 return eina_slstr_printf("%d", value);
69 sprintf(buf, "%d", value);
70} 71}
71 72
72static Eina_Bool 73static Eina_Bool
@@ -249,7 +250,7 @@ _node_scale_change_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info
249static void 250static void
250_countdec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 251_countdec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
251{ 252{
252 char buf[CONVERT]; 253 Eina_Slstr *buf;
253 int tmp; 254 int tmp;
254 255
255 globalGraphical.count -= 10; 256 globalGraphical.count -= 10;
@@ -257,181 +258,183 @@ _countdec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_U
257 else 258 else
258 tmp = ((globalGraphical.count + 1) * (globalGraphical.count + 1)); 259 tmp = ((globalGraphical.count + 1) * (globalGraphical.count + 1));
259 260
260 _value_int_to_char(buf, ((tmp <= 1) ? 0 : tmp), "quantity:"); 261 buf = _value_int_to_char(((tmp <= 1) ? 0 : tmp), "quantity:");
261 elm_object_text_set((Evas_Object*)data, buf); 262 elm_object_text_set((Evas_Object*)data, buf);
262} 263}
263 264
264static void 265static void
265_countdec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 266_countdec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
266{ 267{
267 char buf[CONVERT]; 268 Eina_Slstr *buf;
268 int tmp; 269 int tmp;
270
269 globalGraphical.count--; 271 globalGraphical.count--;
270 if (globalGraphical.count < 0) tmp = globalGraphical.count = 0; 272 if (globalGraphical.count < 0) tmp = globalGraphical.count = 0;
271 else 273 else
272 tmp = ((globalGraphical.count + 1) * (globalGraphical.count + 1)); 274 tmp = ((globalGraphical.count + 1) * (globalGraphical.count + 1));
273 _value_int_to_char(buf, ((tmp <= 1) ? 0 : tmp), "quantity:"); 275 buf = _value_int_to_char(((tmp <= 1) ? 0 : tmp), "quantity:");
274 elm_object_text_set((Evas_Object*)data, buf); 276 elm_object_text_set((Evas_Object*)data, buf);
275} 277}
276 278
277static void 279static void
278_countinc_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 280_countinc_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
279{ 281{
280 char buf[CONVERT]; 282 Eina_Slstr *buf;
281 283
282 globalGraphical.count++; 284 globalGraphical.count++;
283 285
284 _value_int_to_char(buf, ((globalGraphical.count + 1) * (globalGraphical.count + 1)), "quantity:"); 286 buf = _value_int_to_char(((globalGraphical.count + 1) * (globalGraphical.count + 1)), "quantity:");
285 elm_object_text_set((Evas_Object*)data, buf); 287 elm_object_text_set((Evas_Object*)data, buf);
286} 288}
287 289
288static void 290static void
289_countinc10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 291_countinc10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
290{ 292{
291 char buf[CONVERT]; 293 Eina_Slstr *buf;
292 294
293 globalGraphical.count += 10; 295 globalGraphical.count += 10;
294 296
295 _value_int_to_char(buf, ((globalGraphical.count + 1) * (globalGraphical.count + 1)), "quantity:"); 297 buf = _value_int_to_char(((globalGraphical.count + 1) * (globalGraphical.count + 1)), "quantity:");
296 elm_object_text_set((Evas_Object*)data, buf); 298 elm_object_text_set((Evas_Object*)data, buf);
297} 299}
298 300
299static void 301static void
300_speeddec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 302_speeddec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
301{ 303{
302 char buf[CONVERT]; 304 Eina_Slstr *buf;
303 305
304 globalGraphical.speed -= 10; 306 globalGraphical.speed -= 10;
305 if (globalGraphical.speed <= 0) globalGraphical.speed = 10; 307 if (globalGraphical.speed <= 0) globalGraphical.speed = 10;
306 308
307 _value_int_to_char(buf, globalGraphical.speed, "speed:"); 309 buf = _value_int_to_char(globalGraphical.speed, "speed:");
308 elm_object_text_set((Evas_Object*)data, buf); 310 elm_object_text_set((Evas_Object*)data, buf);
309} 311}
310 312
311static void 313static void
312_speeddec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 314_speeddec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
313{ 315{
314 char buf[CONVERT]; 316 Eina_Slstr *buf;
315 317
316 globalGraphical.speed--; 318 globalGraphical.speed--;
317 if (globalGraphical.speed <= 0) globalGraphical.speed = 10; 319 if (globalGraphical.speed <= 0) globalGraphical.speed = 10;
318 320
319 _value_int_to_char(buf, globalGraphical.speed, "speed:"); 321 buf = _value_int_to_char(globalGraphical.speed, "speed:");
320 elm_object_text_set((Evas_Object*)data, buf); 322 elm_object_text_set((Evas_Object*)data, buf);
321} 323}
322 324
323static void 325static void
324_speedinc_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 326_speedinc_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
325{ 327{
326 char buf[CONVERT]; 328 Eina_Slstr *buf;
327 329
328 globalGraphical.speed++; 330 globalGraphical.speed++;
329 331
330 _value_int_to_char(buf, globalGraphical.speed, "speed:"); 332 buf = _value_int_to_char(globalGraphical.speed, "speed:");
331 elm_object_text_set((Evas_Object*)data, buf); 333 elm_object_text_set((Evas_Object*)data, buf);
332} 334}
333 335
334static void 336static void
335_speedinc10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 337_speedinc10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
336{ 338{
337 char buf[CONVERT]; 339 Eina_Slstr *buf;
338 340
339 globalGraphical.speed += 10; 341 globalGraphical.speed += 10;
340 342
341 _value_int_to_char(buf, globalGraphical.speed, "speed:"); 343 buf = _value_int_to_char(globalGraphical.speed, "speed:");
342 elm_object_text_set((Evas_Object*)data, buf); 344 elm_object_text_set((Evas_Object*)data, buf);
343} 345}
344 346
345static void 347static void
346_precisiondec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 348_precisiondec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
347{ 349{
348 char buf[CONVERT]; 350 Eina_Slstr *buf;
349 351
350 globalGraphical.precision -= 10; 352 globalGraphical.precision -= 10;
351 if (globalGraphical.precision <= 0) globalGraphical.precision = 10; 353 if (globalGraphical.precision <= 0) globalGraphical.precision = 10;
352 354
353 _value_int_to_char(buf, globalGraphical.precision, "precision:"); 355 buf = _value_int_to_char(globalGraphical.precision, "precision:");
354 elm_object_text_set((Evas_Object*)data, buf); 356 elm_object_text_set((Evas_Object*)data, buf);
355} 357}
356 358
357static void 359static void
358_precisiondec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 360_precisiondec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
359{ 361{
360 char buf[CONVERT]; 362 Eina_Slstr *buf;
361 363
362 globalGraphical.precision--; 364 globalGraphical.precision--;
363 if (globalGraphical.precision <= 0) globalGraphical.precision = 10; 365 if (globalGraphical.precision <= 0) globalGraphical.precision = 10;
364 366
365 _value_int_to_char(buf, globalGraphical.precision, "precision:"); 367 buf = _value_int_to_char(globalGraphical.precision, "precision:");
366 elm_object_text_set((Evas_Object*)data, buf); 368 elm_object_text_set((Evas_Object*)data, buf);
367} 369}
368 370
369static void 371static void
370_precisioninc_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 372_precisioninc_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
371{ 373{
372 char buf[CONVERT]; 374 Eina_Slstr *buf;
373 375
374 globalGraphical.precision++; 376 globalGraphical.precision++;
375 377
376 _value_int_to_char(buf, globalGraphical.precision, "precision:"); 378 buf = _value_int_to_char(globalGraphical.precision, "precision:");
377 elm_object_text_set((Evas_Object*)data, buf); 379 elm_object_text_set((Evas_Object*)data, buf);
378} 380}
379 381
380static void 382static void
381_precisioninc10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 383_precisioninc10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
382{ 384{
383 char buf[CONVERT]; 385 Eina_Slstr *buf;
384 386
385 globalGraphical.precision += 10; 387 globalGraphical.precision += 10;
386 388
387 _value_int_to_char(buf, globalGraphical.precision, "precision:"); 389 buf = _value_int_to_char(globalGraphical.precision, "precision:");
388 elm_object_text_set((Evas_Object*)data, buf); 390 elm_object_text_set((Evas_Object*)data, buf);
389} 391}
390 392
391static void 393static void
392_angledec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 394_angledec10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
393{ 395{
394 char buf[CONVERT]; 396 Eina_Slstr *buf;
395 397
396 globalGraphical.angle -= 10; 398 globalGraphical.angle -= 10;
397 if (globalGraphical.angle <= 0) globalGraphical.angle = 10; 399 if (globalGraphical.angle <= 0) globalGraphical.angle = 10;
398 400
399 _value_int_to_char(buf, globalGraphical.angle, "angle:"); 401 buf = _value_int_to_char(globalGraphical.angle, "angle:");
400 elm_object_text_set((Evas_Object*)data, buf); 402 elm_object_text_set((Evas_Object*)data, buf);
401} 403}
402 404
403static void 405static void
404_angledec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 406_angledec_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
405{ 407{
406 char buf[CONVERT]; 408 Eina_Slstr *buf;
407 409
408 globalGraphical.angle--; 410 globalGraphical.angle--;
409 if (globalGraphical.angle <= 0) globalGraphical.angle = 10; 411 if (globalGraphical.angle <= 0) globalGraphical.angle = 10;
410 412
411 _value_int_to_char(buf, globalGraphical.angle, "angle:"); 413 buf = _value_int_to_char(globalGraphical.angle, "angle:");
412 elm_object_text_set((Evas_Object*)data, buf); 414 elm_object_text_set((Evas_Object*)data, buf);
413} 415}
414 416
415static void 417static void
416_angleinc_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 418_angleinc_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
417{ 419{
418 char buf[CONVERT]; 420 Eina_Slstr *buf;
419 421
420 globalGraphical.angle++; 422 globalGraphical.angle++;
421 if (globalGraphical.angle >= 180) globalGraphical.angle = 180; 423 if (globalGraphical.angle >= 180) globalGraphical.angle = 180;
422 _value_int_to_char(buf, globalGraphical.angle, "angle:"); 424
425 buf = _value_int_to_char(globalGraphical.angle, "angle:");
423 elm_object_text_set((Evas_Object*)data, buf); 426 elm_object_text_set((Evas_Object*)data, buf);
424} 427}
425 428
426static void 429static void
427_angleinc10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 430_angleinc10_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
428{ 431{
429 char buf[CONVERT]; 432 Eina_Slstr *buf;
430 433
431 globalGraphical.angle += 10; 434 globalGraphical.angle += 10;
432 if (globalGraphical.angle >= 180) globalGraphical.angle = 180; 435 if (globalGraphical.angle >= 180) globalGraphical.angle = 180;
433 436
434 _value_int_to_char(buf, globalGraphical.angle, "angle:"); 437 buf = _value_int_to_char(globalGraphical.angle, "angle:");
435 elm_object_text_set((Evas_Object*)data, buf); 438 elm_object_text_set((Evas_Object*)data, buf);
436} 439}
437 440
@@ -577,7 +580,7 @@ EAPI_MAIN
577 Evas_Object *navigation = NULL; 580 Evas_Object *navigation = NULL;
578 Evas_Object *fs_node = NULL, *bt_orientation = NULL, *bt_position = NULL, *bt_scale = NULL; 581 Evas_Object *fs_node = NULL, *bt_orientation = NULL, *bt_position = NULL, *bt_scale = NULL;
579 Ecore_Timer *fps_timer = NULL; 582 Ecore_Timer *fps_timer = NULL;
580 char buf[CONVERT]; 583 Eina_Slstr *buf;
581 584
582#ifdef ENABLE_ATPORT 585#ifdef ENABLE_ATPORT
583 at_port_h mf_at_port = NULL; 586 at_port_h mf_at_port = NULL;
@@ -692,7 +695,7 @@ EAPI_MAIN
692 evas_object_show(controlbox); 695 evas_object_show(controlbox);
693 696
694 vcount = elm_label_add(win); 697 vcount = elm_label_add(win);
695 _value_int_to_char(buf, 121, "quantity:"); 698 buf = _value_int_to_char(121, "quantity:");
696 elm_object_text_set(vcount, buf); 699 elm_object_text_set(vcount, buf);
697 700
698 countdec10 = elm_button_add(win); 701 countdec10 = elm_button_add(win);
@@ -731,7 +734,7 @@ EAPI_MAIN
731 evas_object_smart_callback_add(countinc10, "clicked", _countinc10_cb, vcount); 734 evas_object_smart_callback_add(countinc10, "clicked", _countinc10_cb, vcount);
732 735
733 vspeed = elm_label_add(win); 736 vspeed = elm_label_add(win);
734 _value_int_to_char(buf, 30, "speed:"); 737 buf = _value_int_to_char(30, "speed:");
735 elm_object_text_set(vspeed, buf); 738 elm_object_text_set(vspeed, buf);
736 739
737 speeddec10 = elm_button_add(win); 740 speeddec10 = elm_button_add(win);
@@ -770,7 +773,7 @@ EAPI_MAIN
770 evas_object_smart_callback_add(speedinc10, "clicked", _speedinc10_cb, vspeed); 773 evas_object_smart_callback_add(speedinc10, "clicked", _speedinc10_cb, vspeed);
771 774
772 vprecision = elm_label_add(win); 775 vprecision = elm_label_add(win);
773 _value_int_to_char(buf, 100, "precision:"); 776 buf = _value_int_to_char(100, "precision:");
774 elm_object_text_set(vprecision, buf); 777 elm_object_text_set(vprecision, buf);
775 778
776 precisiondec10 = elm_button_add(win); 779 precisiondec10 = elm_button_add(win);
@@ -809,7 +812,7 @@ EAPI_MAIN
809 evas_object_smart_callback_add(precisioninc10, "clicked", _precisioninc10_cb, vprecision); 812 evas_object_smart_callback_add(precisioninc10, "clicked", _precisioninc10_cb, vprecision);
810 813
811 vangle = elm_label_add(win); 814 vangle = elm_label_add(win);
812 _value_int_to_char(buf, 120, "angle:"); 815 buf = _value_int_to_char(120, "angle:");
813 elm_object_text_set(vangle, buf); 816 elm_object_text_set(vangle, buf);
814 817
815 angledec10 = elm_button_add(win); 818 angledec10 = elm_button_add(win);
@@ -913,13 +916,13 @@ EAPI_MAIN
913 image = init_graphical_window(image); 916 image = init_graphical_window(image);
914 917
915 /*Update data for count, speed, precision, angle*/ 918 /*Update data for count, speed, precision, angle*/
916 _value_int_to_char(buf, (globalGraphical.count + 1) * (globalGraphical.count + 1), "quantity:"); 919 buf = _value_int_to_char((globalGraphical.count + 1) * (globalGraphical.count + 1), "quantity:");
917 elm_object_text_set(vcount, buf); 920 elm_object_text_set(vcount, buf);
918 _value_int_to_char(buf, globalGraphical.speed, "speed:"); 921 buf = _value_int_to_char(globalGraphical.speed, "speed:");
919 elm_object_text_set(vspeed, buf); 922 elm_object_text_set(vspeed, buf);
920 _value_int_to_char(buf, globalGraphical.precision, "precision:"); 923 buf = _value_int_to_char(globalGraphical.precision, "precision:");
921 elm_object_text_set(vprecision, buf); 924 elm_object_text_set(vprecision, buf);
922 _value_int_to_char(buf, globalGraphical.angle, "angle:"); 925 buf = _value_int_to_char(globalGraphical.angle, "angle:");
923 elm_object_text_set(vangle, buf); 926 elm_object_text_set(vangle, buf);
924 if (globalGraphical.model_path) 927 if (globalGraphical.model_path)
925 evas_object_smart_callback_call(fs_bt, "file,chosen", (void *)globalGraphical.model_path); 928 evas_object_smart_callback_call(fs_bt, "file,chosen", (void *)globalGraphical.model_path);
diff --git a/src/examples/elementary/performance/tools_private.h b/src/examples/elementary/performance/tools_private.h
index 05c3c26..20aa80d 100644
--- a/src/examples/elementary/performance/tools_private.h
+++ b/src/examples/elementary/performance/tools_private.h
@@ -1,5 +1,9 @@
1#define EFL_EO_API_SUPPORT 1#ifndef EFL_EO_API_SUPPORT
2#define EFL_BETA_API_SUPPORT 2# define EFL_EO_API_SUPPORT
3#endif
4#ifndef EFL_BETA_API_SUPPORT
5# define EFL_BETA_API_SUPPORT
6#endif
3 7
4#include <math.h> 8#include <math.h>
5#include <stdlib.h> 9#include <stdlib.h>