warnings--
authorbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 28 Feb 2010 23:27:47 +0000 (23:27 +0000)
committerbarbieri <barbieri@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Sun, 28 Feb 2010 23:27:47 +0000 (23:27 +0000)
Ecore now goes clean on -Wall -Wextra :-)

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@46672 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

16 files changed:
src/lib/ecore/ecore.c
src/lib/ecore/ecore_getopt.c
src/lib/ecore_con/ecore_con.c
src/lib/ecore_con/ecore_con_dns.c
src/lib/ecore_con/ecore_con_info.c
src/lib/ecore_con/ecore_con_local.c
src/lib/ecore_evas/ecore_evas.c
src/lib/ecore_evas/ecore_evas_x.c
src/lib/ecore_file/ecore_file_download.c
src/lib/ecore_imf/ecore_imf_context.c
src/lib/ecore_imf/ecore_imf_module.c
src/lib/ecore_input/ecore_input.c
src/lib/ecore_input_evas/ecore_input_evas.c
src/lib/ecore_x/xlib/ecore_x_events.c
src/lib/ecore_x/xlib/ecore_x_image.c
src/lib/ecore_x/xlib/ecore_x_window.c

index 60c6470..45243bb 100644 (file)
@@ -11,6 +11,7 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <errno.h>
 
 #ifdef HAVE_LOCALE_H
 # include <locale.h>
@@ -261,8 +262,28 @@ _ecore_fps_debug_init(void)
    if (_ecore_fps_debug_fd >= 0)
      {
        unsigned int zero = 0;
+       char *buf = (char *)&zero;
+       ssize_t todo = sizeof(unsigned int);
 
-       write(_ecore_fps_debug_fd, &zero, sizeof(unsigned int));
+       while (todo > 0)
+         {
+            ssize_t r = write(_ecore_fps_debug_fd, buf, todo);
+            if (r > 0)
+              {
+                 todo -= r;
+                 buf += r;
+              }
+            else if ((r < 0) && (errno == EINTR))
+              continue;
+            else
+              {
+                 ERR("could not write to file '%s' fd %d: %s",
+                     tmp, _ecore_fps_debug_fd, strerror(errno));
+                 close(_ecore_fps_debug_fd);
+                 _ecore_fps_debug_fd = -1;
+                 return;
+              }
+         }
        _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int),
                                       PROT_READ | PROT_WRITE,
                                       MAP_SHARED,
index e7c158b..08d5b22 100644 (file)
@@ -46,7 +46,8 @@ _ecore_getopt_help_print_replace_program(FILE *fp, const Ecore_Getopt *parser __
             break;
          }
 
-       fwrite(text, 1, d - text, fp);
+       if (fwrite(text, 1, d - text, fp) != (size_t)(d - text))
+         return;
        d++;
        if (strncmp(d, "prog", sizeof("prog") - 1) == 0)
          {
@@ -115,7 +116,7 @@ _ecore_getopt_help_line(FILE *fp, const int base, const int total, int used, con
 
             if (space)
               {
-                 fwrite(text, 1, i, fp);
+                 i = fwrite(text, 1, i, fp);
                  i++;
                  text += i;
                  len -= i;
@@ -152,7 +153,7 @@ _ecore_getopt_help_line(FILE *fp, const int base, const int total, int used, con
               }
             else
               {
-                 fwrite(text, 1, i, fp);
+                 i = fwrite(text, 1, i, fp);
                  text += i;
                  len -= i;
                  used += i;
index c331c3d..5e77731 100644 (file)
@@ -1126,7 +1126,8 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
    if (svr->delete_me) return 1;
    if ((svr->client_limit >= 0) && (!svr->reject_excess_clients))
      {
-       if (eina_list_count(svr->clients) >= svr->client_limit) return 1;
+       if (eina_list_count(svr->clients) >= (unsigned int)svr->client_limit)
+         return 1;
      }
    /* a new client */
    size_in = sizeof(incoming);
@@ -1139,7 +1140,7 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__)
 
        if ((svr->client_limit >= 0) && (svr->reject_excess_clients))
          {
-           if (eina_list_count(svr->clients) >= svr->client_limit)
+           if (eina_list_count(svr->clients) >= (unsigned int)svr->client_limit)
              {
                close(new_fd);
                return 1;
index 462e924..c6bc8bf 100644 (file)
@@ -36,6 +36,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <ctype.h>
+#include <errno.h>
 #ifdef __OpenBSD__
 # include <sys/types.h>
 #endif
@@ -74,6 +75,7 @@ static void _ecore_con_dns_readdata(CB_Data *cbdata);
 static void _ecore_con_dns_slave_free(CB_Data *cbdata);
 static int _ecore_con_dns_data_handler(void *data, Ecore_Fd_Handler *fd_handler);
 static int _ecore_con_dns_exit_handler(void *data, int type __UNUSED__, void *event);
+static Eina_Bool _ecore_con_write_safe(int fd, void *data, size_t length);
 
 static int dns_init = 0;
 static CB_Data *dns_slaves = NULL;
@@ -138,11 +140,11 @@ ecore_con_dns_lookup(const char *name,
 
             memcpy((struct in_addr *)&addr, he->h_addr,
                    sizeof(struct in_addr));
-            write(fd[1], &(addr.s_addr), sizeof(in_addr_t));
+            _ecore_con_write_safe(fd[1], &(addr.s_addr), sizeof(in_addr_t));
          }
        else
          {
-            write(fd[1], "", 1);
+            _ecore_con_write_safe(fd[1], "", 1);
          }
        close(fd[1]);
 # ifdef __USE_ISOC99
@@ -231,3 +233,28 @@ _ecore_con_dns_exit_handler(void *data, int type __UNUSED__, void *event)
    _ecore_con_dns_slave_free(cbdata);
    return 0;
 }
+
+static Eina_Bool
+_ecore_con_write_safe(int fd, void *data, size_t length)
+{
+   char *buf = data;
+   ssize_t todo = (ssize_t)length;
+
+   while (todo > 0)
+     {
+       ssize_t r = write(fd, buf, todo);
+       if (r > 0)
+         {
+            todo -= r;
+            buf += r;
+         }
+       else if ((r < 0) && (errno == EINTR))
+         continue;
+       else
+         {
+            ERR("could not write to fd %d: %s", fd, strerror(errno));
+            return EINA_FALSE;
+         }
+     }
+   return EINA_TRUE;
+}
index 556640f..4a0ff99 100644 (file)
@@ -315,12 +315,12 @@ _ecore_con_info_readdata(CB_Data *cbdata)
 
        size = read(ecore_main_fd_handler_fd_get(cbdata->fdh), (char *)torecv + sizeof(Ecore_Con_Info),
                    torecv_len - sizeof(Ecore_Con_Info));
-       if (size == torecv_len - sizeof(Ecore_Con_Info))
+       if ((size > 0) && ((size_t)size == torecv_len - sizeof(Ecore_Con_Info)))
          {
            recv = (Ecore_Con_Info *)torecv;
 
            recv->info.ai_addr = (struct sockaddr *)((char *)torecv + sizeof(Ecore_Con_Info));
-           if (torecv_len != (sizeof(Ecore_Con_Info) + recv->info.ai_addrlen))
+           if ((size_t)torecv_len != (sizeof(Ecore_Con_Info) + recv->info.ai_addrlen))
              recv->info.ai_canonname = (char *)torecv + sizeof(Ecore_Con_Info) + recv->info.ai_addrlen;
            else
              recv->info.ai_canonname = NULL;
index 371efcb..20cb224 100644 (file)
@@ -63,7 +63,7 @@ ecore_con_local_shutdown(void)
 int
 ecore_con_local_connect(Ecore_Con_Server *svr,
                        int (*cb_done)(void *data, Ecore_Fd_Handler *fd_handler),
-                       void *data,
+                       void *data __UNUSED__,
                        void (*cb_free)(void *data, void *ev))
 {
    char               buf[4096];
@@ -158,7 +158,7 @@ ecore_con_local_connect(Ecore_Con_Server *svr,
 int
 ecore_con_local_listen(Ecore_Con_Server *svr,
                       int (*cb_listen)(void *data, Ecore_Fd_Handler *fd_handler),
-                      void *data)
+                      void *data __UNUSED__)
 {
    char               buf[4096];
    struct sockaddr_un socket_unix;
index e853342..0fa0fbd 100644 (file)
@@ -9,6 +9,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <errno.h>
 
 #include "Ecore.h"
 #include "ecore_private.h"
@@ -2651,8 +2652,28 @@ _ecore_evas_fps_debug_init(void)
    if (_ecore_evas_fps_debug_fd >= 0)
      {
        unsigned int zero = 0;
+       char *buf = (char *)&zero;
+       ssize_t todo = sizeof(unsigned int);
 
-       write(_ecore_evas_fps_debug_fd, &zero, sizeof(unsigned int));
+       while (todo > 0)
+         {
+            ssize_t r = write(_ecore_evas_fps_debug_fd, buf, todo);
+            if (r > 0)
+              {
+                 todo -= r;
+                 buf += r;
+              }
+            else if ((r < 0) && (errno == EINTR))
+              continue;
+            else
+              {
+                 ERR("could not write to file '%s' fd %d: %s",
+                     buf, _ecore_evas_fps_debug_fd, strerror(errno));
+                 close(_ecore_evas_fps_debug_fd);
+                 _ecore_evas_fps_debug_fd = -1;
+                 return;
+              }
+         }
        _ecore_evas_fps_rendertime_mmap = mmap(NULL, sizeof(unsigned int),
                                               PROT_READ | PROT_WRITE,
                                               MAP_SHARED,
index 479ae03..73fb1fd 100644 (file)
@@ -589,7 +589,7 @@ _ecore_evas_x_event_client_message(void *data __UNUSED__, int type __UNUSED__, v
      {
         ee = ecore_event_window_match(e->data.l[0]);
         if (!ee) return 1; /* pass on event */
-        if (e->data.l[0] != ee->prop.window) return 1;
+        if (e->data.l[0] != (long)ee->prop.window) return 1;
         ee->engine.x.sync_began = 1;
         ee->engine.x.sync_cancel = 0;
      }
@@ -597,7 +597,7 @@ _ecore_evas_x_event_client_message(void *data __UNUSED__, int type __UNUSED__, v
      {
         ee = ecore_event_window_match(e->data.l[0]);
         if (!ee) return 1; /* pass on event */
-        if (e->data.l[0] != ee->prop.window) return 1;
+        if (e->data.l[0] != (long)ee->prop.window) return 1;
         ee->engine.x.sync_began = 0;
         ee->engine.x.sync_cancel = 0;
      }
@@ -605,7 +605,7 @@ _ecore_evas_x_event_client_message(void *data __UNUSED__, int type __UNUSED__, v
      {
         ee = ecore_event_window_match(e->data.l[0]);
         if (!ee) return 1; /* pass on event */
-        if (e->data.l[0] != ee->prop.window) return 1;
+        if (e->data.l[0] != (long)ee->prop.window) return 1;
         ee->engine.x.sync_began = 0;
         ee->engine.x.sync_cancel = 1;
      }
@@ -2396,7 +2396,7 @@ static Ecore_Evas_Engine_Func _ecore_x_engine_func =
 
 #if defined (BUILD_ECORE_EVAS_SOFTWARE_X11) || defined (BUILD_ECORE_EVAS_OPENGL_X11) || defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) || defined (BUILD_ECORE_EVAS_SOFTWARE_16_X11)
 static void
-_ecore_evas_x_flush_pre(void *data, Evas *e, void *event_info)
+_ecore_evas_x_flush_pre(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
 {
    Ecore_Evas *ee = data;
 
@@ -2415,7 +2415,7 @@ _ecore_evas_x_flush_pre(void *data, Evas *e, void *event_info)
 }
 
 static void
-_ecore_evas_x_flush_post(void *data, Evas *e, void *event_info)
+_ecore_evas_x_flush_post(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__)
 {
    Ecore_Evas *ee = data;
    
index 3d02688..70415b8 100644 (file)
@@ -195,7 +195,7 @@ _ecore_file_download_url_compare_job(const void *data1, const void *data2)
 }
 
 static int
-_ecore_file_download_url_complete_cb(void *data, int type, void *event)
+_ecore_file_download_url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
 {
    Ecore_Con_Event_Url_Complete        *ev = event;
    Ecore_File_Download_Job     *job;
@@ -216,7 +216,7 @@ _ecore_file_download_url_complete_cb(void *data, int type, void *event)
 }
 
 static int
-_ecore_file_download_url_progress_cb(void *data, int type, void *event)
+_ecore_file_download_url_progress_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
 {
 /* this reports the downloads progress. if we return 0, then download
  * continues, if we return anything else, then the download stops */
index 09ffc71..1214be0 100644 (file)
@@ -124,7 +124,7 @@ ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type)
        while (p)
          {
             const char *q = strchr(p, ':');
-            int goodness = _ecore_imf_context_match_locale(locale, p, q ? q - p : strlen (p));
+            int goodness = _ecore_imf_context_match_locale(locale, p, q ? (size_t)(q - p) : strlen (p));
 
              if (goodness > best_goodness)
                {
index 957dfd3..2a07b76 100644 (file)
@@ -60,7 +60,7 @@ ecore_imf_module_shutdown(void)
 }
 
 static Eina_Bool
-_hash_module_available_get(const Eina_Hash *hash, int *data, void *list)
+_hash_module_available_get(const Eina_Hash *hash __UNUSED__, int *data, void *list)
 {
   *(Eina_List**)list = eina_list_append(*(Eina_List**)list, data);
   return EINA_TRUE;
@@ -114,7 +114,7 @@ ecore_imf_module_context_create(const char *ctx_id)
 }
 
 static Eina_Bool
-_hash_ids_get(const Eina_Hash *hash, const char *key, void *list)
+_hash_ids_get(const Eina_Hash *hash __UNUSED__, const char *key, void *list)
 {
   *(Eina_List**)list = eina_list_append(*(Eina_List**)list, key);
   return EINA_TRUE;
@@ -139,7 +139,7 @@ ecore_imf_module_context_ids_get(void)
 }
 
 static Eina_Bool
-_hash_ids_by_canvas_type_get(const Eina_Hash *hash, void *data, void *fdata)
+_hash_ids_by_canvas_type_get(const Eina_Hash *hash __UNUSED__, void *data, void *fdata)
 {
    Ecore_IMF_Module *module = data;
    Ecore_IMF_Selector *selector = fdata;
index ffbc893..9ff510f 100644 (file)
@@ -96,7 +96,7 @@ static const Ecore_Event_Modifier_Match matchs[] = {
 EAPI unsigned int
 ecore_event_modifier_mask(Ecore_Event_Modifier modifier)
 {
-   int i;
+   size_t i;
 
    for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++)
      if (matchs[i].modifier == modifier)
@@ -108,7 +108,7 @@ ecore_event_modifier_mask(Ecore_Event_Modifier modifier)
 EAPI Ecore_Event_Modifier
 ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc)
 {
-   int i;
+   size_t i;
 
    for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++)
      if (strcmp(matchs[i].key, key) == 0)
index 59b7f75..d861f55 100644 (file)
@@ -330,7 +330,7 @@ ecore_event_evas_init(void)
 EAPI int
 ecore_event_evas_shutdown(void)
 {
-   int i;
+   size_t i;
 
    if (--_ecore_event_evas_init_count != 0)
      return _ecore_event_evas_init_count;
index 28cf663..a30f610 100644 (file)
@@ -1731,7 +1731,7 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
        e->state[0] = _ecore_x_netwm_state_get(xevent->xclient.data.l[1]);
        if (e->state[0] == ECORE_X_WINDOW_STATE_UNKNOWN)
          {
-            char *name;
+//          char *name;
 
              LOGFN(__FILE__, __LINE__, __FUNCTION__);
 //          name = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[1]);
@@ -1741,7 +1741,7 @@ _ecore_x_event_handle_client_message(XEvent *xevent)
        e->state[1] = _ecore_x_netwm_state_get(xevent->xclient.data.l[2]);
        if (e->state[1] == ECORE_X_WINDOW_STATE_UNKNOWN)
          {
-            char *name;
+//          char *name;
 
              LOGFN(__FILE__, __LINE__, __FUNCTION__);
 //          name = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[2]);
index a0c2923..aaa4ba0 100644 (file)
 #include <sys/shm.h>
 #include <string.h>
 
-static int _composite_available;
-
 static int _ecore_x_image_shm_can = -1;
 static int _ecore_x_image_err = 0;
 
 static void
-_ecore_x_image_error_handler(Display * d, XErrorEvent * ev)
+_ecore_x_image_error_handler(Display * d __UNUSED__, XErrorEvent * ev __UNUSED__)
 {
    _ecore_x_image_err = 1;
 }
@@ -179,7 +177,7 @@ _ecore_x_image_shm_create(Ecore_X_Image *im)
      } 
    XShmAttach(_ecore_x_disp, &im->shminfo);
    
-   im->data = im->xim->data;
+   im->data = (unsigned char *)im->xim->data;
 
    im->bpl = im->xim->bytes_per_line;
    im->rows = im->xim->height;
@@ -205,7 +203,7 @@ ecore_x_image_get(Ecore_X_Image *im, Ecore_X_Drawable draw,
         ph = XSetErrorHandler((XErrorHandler)_ecore_x_image_error_handler);
         if ((sx == 0) && (w == im->w))
           {
-             im->xim->data = 
+             im->xim->data = (char *)
                im->data + (im->xim->bytes_per_line * sy) + (sx * im->bpp);
              im->xim->width = w;
              im->xim->height = h;
@@ -256,8 +254,7 @@ ecore_x_image_get(Ecore_X_Image *im, Ecore_X_Drawable draw,
 }
 
 EAPI void
-ecore_x_image_put(Ecore_X_Image *im, Ecore_X_Drawable draw, 
-                  int x, int y, int sx, int sy, int w, int h)
+ecore_x_image_put(Ecore_X_Image *im __UNUSED__, Ecore_X_Drawable draw __UNUSED__, int x __UNUSED__, int y __UNUSED__, int sx __UNUSED__, int sy __UNUSED__, int w __UNUSED__, int h __UNUSED__)
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
    printf("ecore_x_image_put: unimplemented!\n");
index eed980a..2067def 100644 (file)
@@ -748,7 +748,6 @@ struct _Shadow
    unsigned short  w, h;
 };
 
-static int shadow_count = 0;
 static Shadow **shadow_base = NULL;
 static int shadow_num = 0;
 
@@ -757,7 +756,6 @@ _ecore_x_window_tree_walk(Window win)
 {
    Window           *list = NULL;
    Window            parent_win = 0, root_win = 0;
-   int               i, j;
    unsigned int      num;
    Shadow           *s, **sl;
    XWindowAttributes att;
@@ -779,6 +777,7 @@ _ecore_x_window_tree_walk(Window win)
        s->children = calloc(1, sizeof(Shadow *) * num);
        if (s->children)
          {
+            size_t i, j;
             s->children_num = num;
             for (i = 0; i < num; i++)
               {
@@ -867,6 +866,9 @@ _ecore_x_window_tree_shadow_populate(void)
      }
 }
 
+/*
+static int shadow_count = 0;
+
 static void
 _ecore_x_window_tree_shadow_start(void)
 {
@@ -882,6 +884,7 @@ _ecore_x_window_tree_shadow_stop(void)
    if (shadow_count != 0) return;
    _ecore_x_window_tree_shadow_free();
 }
+*/
 
 static Shadow *
 _ecore_x_window_shadow_tree_find_shadow(Shadow *s, Window win)
@@ -1005,7 +1008,7 @@ ecore_x_window_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base, int x, int y
  * @ingroup Ecore_X_Window_Geometry_Group
  */
 EAPI Ecore_X_Window
-ecore_x_window_shadow_parent_get(Ecore_X_Window root, Ecore_X_Window win)
+ecore_x_window_shadow_parent_get(Ecore_X_Window root __UNUSED__, Ecore_X_Window win)
 {
    Shadow *s;
    int i;