summaryrefslogtreecommitdiff
path: root/legacy/ethumb
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2010-03-02 00:34:40 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2010-03-02 00:34:40 +0000
commit9345b211b0441ca431fc71b99c8ae89bb986d5be (patch)
tree4e95e959f3a5f107b0a73579bee67753ad5b0935 /legacy/ethumb
parentd99f80aff77da19c1d4fcba9344a002bc8818f98 (diff)
fix llvm/clang and gcc errors.
NOTE: mixing write() and fprintf() to the same descriptor (stderr, done by ERR()), will likely cause problems :-/ SVN revision: 46753
Diffstat (limited to 'legacy/ethumb')
-rw-r--r--legacy/ethumb/src/bin/ethumbd.c50
-rw-r--r--legacy/ethumb/src/bin/ethumbd_client.c2
-rw-r--r--legacy/ethumb/src/lib/Ethumb.c6
-rw-r--r--legacy/ethumb/src/plugins/emotion/emotion.c1
4 files changed, 53 insertions, 6 deletions
diff --git a/legacy/ethumb/src/bin/ethumbd.c b/legacy/ethumb/src/bin/ethumbd.c
index 0401d7902c..8faec801b3 100644
--- a/legacy/ethumb/src/bin/ethumbd.c
+++ b/legacy/ethumb/src/bin/ethumbd.c
@@ -48,6 +48,7 @@
48#define INF(...) EINA_LOG_INFO(__VA_ARGS__) 48#define INF(...) EINA_LOG_INFO(__VA_ARGS__)
49#define WRN(...) EINA_LOG_WARN(__VA_ARGS__) 49#define WRN(...) EINA_LOG_WARN(__VA_ARGS__)
50#define ERR(...) EINA_LOG_ERR(__VA_ARGS__) 50#define ERR(...) EINA_LOG_ERR(__VA_ARGS__)
51#define CRIT(...) EINA_LOG_CRIT(__VA_ARGS__)
51 52
52static const char _ethumb_dbus_bus_name[] = "org.enlightenment.Ethumb"; 53static const char _ethumb_dbus_bus_name[] = "org.enlightenment.Ethumb";
53static const char _ethumb_dbus_interface[] = "org.enlightenment.Ethumb"; 54static const char _ethumb_dbus_interface[] = "org.enlightenment.Ethumb";
@@ -354,6 +355,28 @@ _generated_cb(struct _Ethumbd *ed, Eina_Bool success, const char *thumb_path, co
354 ed->processing = NULL; 355 ed->processing = NULL;
355} 356}
356 357
358static Eina_Bool
359_write_safe(int fd, void *data, size_t size)
360{
361 unsigned char *buf = data;
362 size_t todo = size;
363 while (todo > 0)
364 {
365 size_t r = write(fd, buf, todo);
366 if (r > 0)
367 {
368 todo -= r;
369 buf += r;
370 }
371 else if ((r < 0) && (errno != EINTR))
372 {
373 ERR("could not write to fd=%d: %s", fd, strerror(errno));
374 return EINA_FALSE;
375 }
376 }
377 return EINA_TRUE;
378}
379
357static void 380static void
358_ethumbd_slave_cmd_ready(struct _Ethumbd *ed) 381_ethumbd_slave_cmd_ready(struct _Ethumbd *ed)
359{ 382{
@@ -369,7 +392,7 @@ _ethumbd_slave_cmd_ready(struct _Ethumbd *ed)
369 size_path = (int *)bufcmd; 392 size_path = (int *)bufcmd;
370 bufcmd += sizeof(*size_path); 393 bufcmd += sizeof(*size_path);
371 394
372 write(STDERR_FILENO, bufcmd, ed->slave.scmd); 395 _write_safe(STDERR_FILENO, bufcmd, ed->slave.scmd);
373 396
374 thumb_path = bufcmd; 397 thumb_path = bufcmd;
375 bufcmd += *size_path; 398 bufcmd += *size_path;
@@ -423,7 +446,8 @@ _ethumbd_slave_data_read_cb(void *data, int type, void *event)
423 ssize = ev->size; 446 ssize = ev->size;
424 sdata = ev->data; 447 sdata = ev->data;
425 448
426 write(STDERR_FILENO, sdata, ssize); 449 if (!_write_safe(STDERR_FILENO, sdata, ssize))
450 return 0;
427 451
428 while (ssize > 0) 452 while (ssize > 0)
429 { 453 {
@@ -713,14 +737,30 @@ _ethumb_table_append(struct _Ethumbd *ed)
713 { 737 {
714 int new_max = q->max_count + 5; 738 int new_max = q->max_count + 5;
715 int start, size; 739 int start, size;
740 void *tmp;
716 741
717 start = q->max_count; 742 start = q->max_count;
718 size = new_max - q->max_count; 743 size = new_max - q->max_count;
719 744
720 q->table = realloc(q->table, new_max * sizeof(struct _Ethumb_Object)); 745 tmp = realloc(q->table, new_max * sizeof(struct _Ethumb_Object));
721 q->list = realloc(q->list, new_max * sizeof(int)); 746 if (!tmp)
747 {
748 CRIT("could not realloc q->table to %zd bytes: %s",
749 new_max * sizeof(struct _Ethumb_Object), strerror(errno));
750 return -1;
751 }
752 q->table = tmp;
722 memset(&q->table[start], 0, size * sizeof(struct _Ethumb_Object)); 753 memset(&q->table[start], 0, size * sizeof(struct _Ethumb_Object));
723 754
755 tmp = realloc(q->list, new_max * sizeof(int));
756 if (!tmp)
757 {
758 CRIT("could not realloc q->list to %zd bytes: %s",
759 new_max * sizeof(int), strerror(errno));
760 return -1;
761 }
762 q->list = tmp;
763
724 q->max_count = new_max; 764 q->max_count = new_max;
725 } 765 }
726 766
@@ -874,6 +914,8 @@ _ethumb_dbus_ethumb_new_cb(E_DBus_Object *object, DBusMessage *msg)
874 goto end_new; 914 goto end_new;
875 915
876 i = _ethumb_table_append(ed); 916 i = _ethumb_table_append(ed);
917 if (i < 0)
918 goto end_new;
877 919
878 odata = calloc(1, sizeof(*odata)); 920 odata = calloc(1, sizeof(*odata));
879 odata->index = i; 921 odata->index = i;
diff --git a/legacy/ethumb/src/bin/ethumbd_client.c b/legacy/ethumb/src/bin/ethumbd_client.c
index edf2d131a0..a5166fdd2d 100644
--- a/legacy/ethumb/src/bin/ethumbd_client.c
+++ b/legacy/ethumb/src/bin/ethumbd_client.c
@@ -223,7 +223,7 @@ main(int argc, char *argv[])
223{ 223{
224 Ethumb_Client *c; 224 Ethumb_Client *c;
225 Eina_Bool quit_option = 0; 225 Eina_Bool quit_option = 0;
226 const char *format_str, *aspect_str; 226 const char *format_str = NULL, *aspect_str;
227 struct options opts = { 227 struct options opts = {
228 {-1, -1, -1, -1}, 228 {-1, -1, -1, -1},
229 0, 0, 229 0, 0,
diff --git a/legacy/ethumb/src/lib/Ethumb.c b/legacy/ethumb/src/lib/Ethumb.c
index 995f7d122d..ee08c0e04f 100644
--- a/legacy/ethumb/src/lib/Ethumb.c
+++ b/legacy/ethumb/src/lib/Ethumb.c
@@ -910,6 +910,12 @@ _ethumb_file_generate_path(Ethumb *e)
910 category = eina_stringshare_ref(_thumb_category_normal); 910 category = eina_stringshare_ref(_thumb_category_normal);
911 else if (e->tw == THUMB_SIZE_LARGE) 911 else if (e->tw == THUMB_SIZE_LARGE)
912 category = eina_stringshare_ref(_thumb_category_large); 912 category = eina_stringshare_ref(_thumb_category_large);
913 else
914 {
915 ERR("fdo_format but size %d is not NORMAL (%d) or LARGE (%d)?",
916 e->tw, THUMB_SIZE_NORMAL, THUMB_SIZE_LARGE);
917 category = "unknown";
918 }
913 } 919 }
914 920
915 if (e->format == ETHUMB_THUMB_FDO) 921 if (e->format == ETHUMB_THUMB_FDO)
diff --git a/legacy/ethumb/src/plugins/emotion/emotion.c b/legacy/ethumb/src/plugins/emotion/emotion.c
index efa04979d8..b3f59507ac 100644
--- a/legacy/ethumb/src/plugins/emotion/emotion.c
+++ b/legacy/ethumb/src/plugins/emotion/emotion.c
@@ -317,7 +317,6 @@ _generate_thumb(Ethumb *e)
317 _plugin->video = o; 317 _plugin->video = o;
318 318
319 ethumb_file_get(e, &file, NULL); 319 ethumb_file_get(e, &file, NULL);
320 ethumb_video_start_get(e);
321 f = ethumb_thumb_format_get(e); 320 f = ethumb_thumb_format_get(e);
322 321
323 emotion_object_file_set(o, file); 322 emotion_object_file_set(o, file);