summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2013-10-29 13:54:15 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2013-10-29 15:08:14 +0900
commit10f80df01825066987452b11a9ec785555540c64 (patch)
tree0c3638f3c40ddca5f80b64e20f414d97c10a5c6d /src
parent73c2ae44e0ae7404c64e2da1c0220301392a2220 (diff)
evas/cserve2: Fix new Coverity issues
Nothing extraordinary here. Most potential crashes are extremely unlikely. - Fix CID 1113444 - Fix CID 1113442 - Fix CID 1113441 (Logically dead code, can not be NULL) - Fix CID 1113440: Explicit null dereferenced This is actually an impossible situation. Fixed by checking for nullity and printing out some error messages instead of just crashing. - Fix CID 1113439: Dereference after null check Logically impossible code as both idxpath and datapath must be either set or null at the same time. Change the if logic to tell Coverity there's no bug. - Fix CID 1113438 (Argument cannot be negative) Fix wrong check of return value from shm_open. - Fix CID 1113437 (Argument cannot be negative) Fix wrong check of return value from shm_open. - Fix CID 1113436 (Dereference null return value) This case really shouldn't happen. But the extra check does not hurt. - Fix CID 1113435 (Dereference before null check) Check for nullity after map open. - Fix CID 1113434 (Extra sizeof expression) Debug buggy debug tool :) - Fix CID 1113433 (Uninitialized scalar variable) Insignificant issue: only prints wrong debug logs :) - Fix CID 1113431 (Uninitialized scalar value) Check if (!found) only to print out logs. Not a big deal if found was invalid. - Fix CID 1039462 (Logically dead code)
Diffstat (limited to 'src')
-rw-r--r--src/bin/evas/dummy_slave.c2
-rw-r--r--src/bin/evas/evas_cserve2_cache.c10
-rw-r--r--src/bin/evas/evas_cserve2_index.c2
-rw-r--r--src/bin/evas/evas_cserve2_shm.c4
-rw-r--r--src/bin/evas/evas_cserve2_shm_debug.c4
-rw-r--r--src/lib/evas/cache2/evas_cache2.c2
-rw-r--r--src/lib/evas/cserve2/evas_cs2_client.c19
7 files changed, 26 insertions, 17 deletions
diff --git a/src/bin/evas/dummy_slave.c b/src/bin/evas/dummy_slave.c
index a64ec53d90..9b5638053b 100644
--- a/src/bin/evas/dummy_slave.c
+++ b/src/bin/evas/dummy_slave.c
@@ -170,7 +170,7 @@ int main(int c, char **v)
170 Error_Type err; 170 Error_Type err;
171 const char *file, *key; 171 const char *file, *key;
172 p = params; 172 p = params;
173 file = (const char *)(p + sizeof(*p)); 173 file = (const char *)(p + 1);
174 key = file + strlen(file) + 1; 174 key = file + strlen(file) + 1;
175 if ((err = image_open(file, key, &result)) != CSERVE2_NONE) 175 if ((err = image_open(file, key, &result)) != CSERVE2_NONE)
176 error_send(wfd, err); 176 error_send(wfd, err);
diff --git a/src/bin/evas/evas_cserve2_cache.c b/src/bin/evas/evas_cserve2_cache.c
index 9f92543919..4c20a72d33 100644
--- a/src/bin/evas/evas_cserve2_cache.c
+++ b/src/bin/evas/evas_cserve2_cache.c
@@ -1588,8 +1588,8 @@ _image_entry_new(Client *client, int rid,
1588 ref = eina_hash_find(client->files.referencing, &client_file_id); 1588 ref = eina_hash_find(client->files.referencing, &client_file_id);
1589 if (!ref) 1589 if (!ref)
1590 { 1590 {
1591 ERR("Couldn't find file id: %d, for image id: %d", 1591 ERR("Couldn't find file id for client image id: %d",
1592 client_file_id, image_id); 1592 client_file_id);
1593 cserve2_client_error_send(client, rid, 1593 cserve2_client_error_send(client, rid,
1594 CSERVE2_INVALID_CACHE); 1594 CSERVE2_INVALID_CACHE);
1595 return NULL; 1595 return NULL;
@@ -2373,7 +2373,7 @@ _font_entry_debug_size_cb(const Eina_Hash *hash EINA_UNUSED,
2373 // name 2373 // name
2374 if (fe->src->name) 2374 if (fe->src->name)
2375 { 2375 {
2376 str = cserve2_shared_string_get(fe->src->file); 2376 str = cserve2_shared_string_get(fe->src->name);
2377 di->size+= strlen(str) + 1; 2377 di->size+= strlen(str) + 1;
2378 } 2378 }
2379 2379
@@ -2769,8 +2769,10 @@ try_again:
2769 0, &unscaled, buf, sizeof(buf)); 2769 0, &unscaled, buf, sizeof(buf));
2770 if (!orig_entry) return -1; 2770 if (!orig_entry) return -1;
2771 2771
2772 image_id = orig_entry->base.id;
2773 orig_data = _image_data_find(ENTRYID(orig_entry)); 2772 orig_data = _image_data_find(ENTRYID(orig_entry));
2773 if (!orig_data) return -1;
2774
2775 image_id = ENTRYID(orig_entry);
2774 orig_data->unused = EINA_TRUE; 2776 orig_data->unused = EINA_TRUE;
2775 fentry = _file_entry_find(orig_data->file_id); 2777 fentry = _file_entry_find(orig_data->file_id);
2776 fentry->images = eina_list_append(fentry->images, orig_entry); 2778 fentry->images = eina_list_append(fentry->images, orig_entry);
diff --git a/src/bin/evas/evas_cserve2_index.c b/src/bin/evas/evas_cserve2_index.c
index e6b13ce93e..f0d6f71a58 100644
--- a/src/bin/evas/evas_cserve2_index.c
+++ b/src/bin/evas/evas_cserve2_index.c
@@ -581,8 +581,6 @@ _shared_index_entry_get_by_id(Shared_Index *si, unsigned int id)
581 for (cur = start_high; cur < si->sa->header->count; cur++) 581 for (cur = start_high; cur < si->sa->header->count; cur++)
582 { 582 {
583 obj = (Index_Entry *) (base + (elemsize * cur)); 583 obj = (Index_Entry *) (base + (elemsize * cur));
584 if (!obj)
585 return NULL;
586 if (!obj->id) 584 if (!obj->id)
587 return NULL; 585 return NULL;
588 if (obj->id == id) 586 if (obj->id == id)
diff --git a/src/bin/evas/evas_cserve2_shm.c b/src/bin/evas/evas_cserve2_shm.c
index d95afc7782..6ccfbcd2a4 100644
--- a/src/bin/evas/evas_cserve2_shm.c
+++ b/src/bin/evas/evas_cserve2_shm.c
@@ -132,7 +132,7 @@ cserve2_shm_segment_request(Shm_Handle *shm, size_t size)
132 if (!segment) return NULL; 132 if (!segment) return NULL;
133 133
134 fd = shm_open(map->name, O_RDWR, S_IRUSR | S_IWUSR); 134 fd = shm_open(map->name, O_RDWR, S_IRUSR | S_IWUSR);
135 if (!fd) 135 if (fd == -1)
136 { 136 {
137 ERR("Could not reopen shm handle: %m"); 137 ERR("Could not reopen shm handle: %m");
138 free(segment); 138 free(segment);
@@ -184,7 +184,7 @@ cserve2_shm_resize(Shm_Handle *shm, size_t newsize)
184 } 184 }
185 185
186 fd = shm_open(shm->mapping->name, O_RDWR, S_IRUSR | S_IWUSR); 186 fd = shm_open(shm->mapping->name, O_RDWR, S_IRUSR | S_IWUSR);
187 if (!fd) 187 if (fd == -1)
188 { 188 {
189 ERR("Could not reopen shm handle: %m"); 189 ERR("Could not reopen shm handle: %m");
190 return NULL; 190 return NULL;
diff --git a/src/bin/evas/evas_cserve2_shm_debug.c b/src/bin/evas/evas_cserve2_shm_debug.c
index 10bb48453e..73b13b3e78 100644
--- a/src/bin/evas/evas_cserve2_shm_debug.c
+++ b/src/bin/evas/evas_cserve2_shm_debug.c
@@ -725,8 +725,8 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED)
725 725
726 if (isatty(STDOUT_FILENO)) 726 if (isatty(STDOUT_FILENO))
727 { 727 {
728 ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); 728 if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == 0)
729 _termsize = w.ws_col; 729 _termsize = w.ws_col;
730 } 730 }
731 731
732 if (argc > 1) 732 if (argc > 1)
diff --git a/src/lib/evas/cache2/evas_cache2.c b/src/lib/evas/cache2/evas_cache2.c
index e1a9d01120..35cceb6e65 100644
--- a/src/lib/evas/cache2/evas_cache2.c
+++ b/src/lib/evas/cache2/evas_cache2.c
@@ -657,7 +657,7 @@ evas_cache2_image_open(Evas_Cache2 *cache, const char *path, const char *key,
657 Image_Timestamp tstamp; 657 Image_Timestamp tstamp;
658 Evas_Image_Load_Opts prevent; 658 Evas_Image_Load_Opts prevent;
659 659
660 if ((!path) || ((!path) && (!key))) 660 if (!path)
661 { 661 {
662 *error = EVAS_LOAD_ERROR_GENERIC; 662 *error = EVAS_LOAD_ERROR_GENERIC;
663 return NULL; 663 return NULL;
diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c
index 67c597a0cf..5410b0b212 100644
--- a/src/lib/evas/cserve2/evas_cs2_client.c
+++ b/src/lib/evas/cserve2/evas_cs2_client.c
@@ -545,7 +545,7 @@ _server_dispatch(Eina_Bool *failed)
545 Eina_List *l, *l_next; 545 Eina_List *l, *l_next;
546 Client_Request *cr; 546 Client_Request *cr;
547 Msg_Base *msg; 547 Msg_Base *msg;
548 Eina_Bool found; 548 Eina_Bool found = EINA_FALSE;
549 549
550 msg = _server_read(&size); 550 msg = _server_read(&size);
551 if (!msg) 551 if (!msg)
@@ -1691,8 +1691,9 @@ _glyph_map_remap_check(Glyph_Map *map, const char *idxpath, const char *datapath
1691 // Note: Since the shm name contains cserve2's PID it should most likely 1691 // Note: Since the shm name contains cserve2's PID it should most likely
1692 // always change in case of crash/restart 1692 // always change in case of crash/restart
1693 1693
1694 if ((datapath && strcmp(datapath, map->mempool.path)) 1694 if (datapath && idxpath &&
1695 || (idxpath && strcmp(idxpath, map->index.path))) 1695 ((strncmp(datapath, map->mempool.path, SHARED_BUFFER_PATH_MAX) != 0) ||
1696 (strncmp(idxpath, map->index.path, SHARED_BUFFER_PATH_MAX) != 0)))
1696 { 1697 {
1697 CS_Glyph_Out *gl, *cursor; 1698 CS_Glyph_Out *gl, *cursor;
1698 1699
@@ -1735,7 +1736,13 @@ _glyph_map_remap_check(Glyph_Map *map, const char *idxpath, const char *datapath
1735 else 1736 else
1736 { 1737 {
1737 gl->sb = oldbuf; 1738 gl->sb = oldbuf;
1738 EINA_REFCOUNT_REF(gl->sb); 1739 if (gl->sb)
1740 EINA_REFCOUNT_REF(gl->sb);
1741 else
1742 {
1743 ERR("Glyph pool can not be remapped! (invalid refs)");
1744 eina_clist_remove(&gl->map_entry);
1745 }
1739 } 1746 }
1740 } 1747 }
1741 1748
@@ -1824,11 +1831,13 @@ _font_entry_glyph_map_rebuild_check(Font_Entry *fe, Font_Hint_Flags hints)
1824 if (!idxpath || !datapath) return -1; 1831 if (!idxpath || !datapath) return -1;
1825 1832
1826 fe->map =_glyph_map_open(fe, idxpath, datapath); 1833 fe->map =_glyph_map_open(fe, idxpath, datapath);
1834 if (!fe->map) return -1;
1835
1827 changed = EINA_TRUE; 1836 changed = EINA_TRUE;
1828 } 1837 }
1829 1838
1830 changed |= _glyph_map_remap_check(fe->map, idxpath, datapath); 1839 changed |= _glyph_map_remap_check(fe->map, idxpath, datapath);
1831 if (changed && fe->map && fe->map->index.data && fe->map->mempool.data) 1840 if (changed && fe->map->index.data && fe->map->mempool.data)
1832 { 1841 {
1833 CS_Glyph_Out *gl; 1842 CS_Glyph_Out *gl;
1834 const Glyph_Data *gd; 1843 const Glyph_Data *gd;