summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-08-08 18:16:07 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-08-08 18:16:07 +0200
commitb955575d6e5b35341982c64ab9053c31b1e42a48 (patch)
tree087a31cb0359a36d4fbd21da87738adbfd41c947
parent6cd94fad12ca4e038aac409e8e1cb9a332a80a39 (diff)
afb-evt: fix a bug discovered by clang-check
Change-Id: I6bb1dffeb17fdcaf6e3a2686651d35dd0b0500b9 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-evt.c14
-rw-r--r--src/locale-root.c3
2 files changed, 7 insertions, 10 deletions
diff --git a/src/afb-evt.c b/src/afb-evt.c
index 0979db82..1c81fd53 100644
--- a/src/afb-evt.c
+++ b/src/afb-evt.c
@@ -312,7 +312,7 @@ static void evt_destroy(struct afb_evt_event *evt)
struct afb_event afb_evt_create_event(const char *name)
{
size_t len;
- struct afb_evt_event *evt;
+ struct afb_evt_event *evt, *oevt;
/* allocates the event */
len = strlen(name);
@@ -320,10 +320,6 @@ struct afb_event afb_evt_create_event(const char *name)
if (evt == NULL)
goto error;
- /* initialize the event */
- evt->watchs = NULL;
- memcpy(evt->name, name, len + 1);
-
/* allocates the id */
pthread_mutex_lock(&events_mutex);
do {
@@ -333,10 +329,10 @@ struct afb_event afb_evt_create_event(const char *name)
}
if (!event_id_wrapped)
break;
- evt = events;
- while(evt != NULL && evt->id != event_id_counter)
- evt = evt->next;
- } while (evt != NULL);
+ oevt = events;
+ while(oevt != NULL && oevt->id != event_id_counter)
+ oevt = oevt->next;
+ } while (oevt != NULL);
/* initialize the event */
memcpy(evt->name, name, len + 1);
diff --git a/src/locale-root.c b/src/locale-root.c
index ece4456f..8386e669 100644
--- a/src/locale-root.c
+++ b/src/locale-root.c
@@ -263,7 +263,8 @@ static int init_container(struct locale_container *container, int dirfd)
}
/* sort the folders */
- qsort(container->folders, container->count, sizeof *container->folders, compare_folders_for_qsort);
+ if (container->count)
+ qsort(container->folders, container->count, sizeof *container->folders, compare_folders_for_qsort);
/* build the parents links */
i = container->count;