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
This commit is contained in:
Gustavo Sverzut Barbieri 2010-03-02 00:34:40 +00:00
parent d99f80aff7
commit 9345b211b0
4 changed files with 53 additions and 6 deletions

View File

@ -48,6 +48,7 @@
#define INF(...) EINA_LOG_INFO(__VA_ARGS__)
#define WRN(...) EINA_LOG_WARN(__VA_ARGS__)
#define ERR(...) EINA_LOG_ERR(__VA_ARGS__)
#define CRIT(...) EINA_LOG_CRIT(__VA_ARGS__)
static const char _ethumb_dbus_bus_name[] = "org.enlightenment.Ethumb";
static 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
ed->processing = NULL;
}
static Eina_Bool
_write_safe(int fd, void *data, size_t size)
{
unsigned char *buf = data;
size_t todo = size;
while (todo > 0)
{
size_t r = write(fd, buf, todo);
if (r > 0)
{
todo -= r;
buf += r;
}
else if ((r < 0) && (errno != EINTR))
{
ERR("could not write to fd=%d: %s", fd, strerror(errno));
return EINA_FALSE;
}
}
return EINA_TRUE;
}
static void
_ethumbd_slave_cmd_ready(struct _Ethumbd *ed)
{
@ -369,7 +392,7 @@ _ethumbd_slave_cmd_ready(struct _Ethumbd *ed)
size_path = (int *)bufcmd;
bufcmd += sizeof(*size_path);
write(STDERR_FILENO, bufcmd, ed->slave.scmd);
_write_safe(STDERR_FILENO, bufcmd, ed->slave.scmd);
thumb_path = bufcmd;
bufcmd += *size_path;
@ -423,7 +446,8 @@ _ethumbd_slave_data_read_cb(void *data, int type, void *event)
ssize = ev->size;
sdata = ev->data;
write(STDERR_FILENO, sdata, ssize);
if (!_write_safe(STDERR_FILENO, sdata, ssize))
return 0;
while (ssize > 0)
{
@ -713,14 +737,30 @@ _ethumb_table_append(struct _Ethumbd *ed)
{
int new_max = q->max_count + 5;
int start, size;
void *tmp;
start = q->max_count;
size = new_max - q->max_count;
q->table = realloc(q->table, new_max * sizeof(struct _Ethumb_Object));
q->list = realloc(q->list, new_max * sizeof(int));
tmp = realloc(q->table, new_max * sizeof(struct _Ethumb_Object));
if (!tmp)
{
CRIT("could not realloc q->table to %zd bytes: %s",
new_max * sizeof(struct _Ethumb_Object), strerror(errno));
return -1;
}
q->table = tmp;
memset(&q->table[start], 0, size * sizeof(struct _Ethumb_Object));
tmp = realloc(q->list, new_max * sizeof(int));
if (!tmp)
{
CRIT("could not realloc q->list to %zd bytes: %s",
new_max * sizeof(int), strerror(errno));
return -1;
}
q->list = tmp;
q->max_count = new_max;
}
@ -874,6 +914,8 @@ _ethumb_dbus_ethumb_new_cb(E_DBus_Object *object, DBusMessage *msg)
goto end_new;
i = _ethumb_table_append(ed);
if (i < 0)
goto end_new;
odata = calloc(1, sizeof(*odata));
odata->index = i;

View File

@ -223,7 +223,7 @@ main(int argc, char *argv[])
{
Ethumb_Client *c;
Eina_Bool quit_option = 0;
const char *format_str, *aspect_str;
const char *format_str = NULL, *aspect_str;
struct options opts = {
{-1, -1, -1, -1},
0, 0,

View File

@ -910,6 +910,12 @@ _ethumb_file_generate_path(Ethumb *e)
category = eina_stringshare_ref(_thumb_category_normal);
else if (e->tw == THUMB_SIZE_LARGE)
category = eina_stringshare_ref(_thumb_category_large);
else
{
ERR("fdo_format but size %d is not NORMAL (%d) or LARGE (%d)?",
e->tw, THUMB_SIZE_NORMAL, THUMB_SIZE_LARGE);
category = "unknown";
}
}
if (e->format == ETHUMB_THUMB_FDO)

View File

@ -317,7 +317,6 @@ _generate_thumb(Ethumb *e)
_plugin->video = o;
ethumb_file_get(e, &file, NULL);
ethumb_video_start_get(e);
f = ethumb_thumb_format_get(e);
emotion_object_file_set(o, file);