From 4de99dea9074944525a2148a13f62d3952de4909 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 29 Mar 2019 10:24:51 +0100 Subject: Test directory existence Missing testing the readdir returned value. Bug-AGL: SPEC-2288 Change-Id: I38691f2604ed4a13ff90e53dd5303e8ddcba7cf1 Signed-off-by: Romain Forlot --- src/platform-info-binding.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/platform-info-binding.c b/src/platform-info-binding.c index c6bc9fd..c373d53 100644 --- a/src/platform-info-binding.c +++ b/src/platform-info-binding.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016, 2018 "IoT.bzh" + * Copyright (C) 2016-2019 "IoT.bzh" * * Author "Romain Forlot" * @@ -86,7 +86,12 @@ void afv_subscribe(afb_req_t req) { int init(afb_api_t api) { struct dirent* dir_ent = NULL; + DIR* dir_handle = opendir(PLATFORM_INFO_DIR); + if (! dir_handle) { + AFB_ERROR("The directory %s does not exist.", PLATFORM_INFO_DIR); + return -1; + } json_object *json_file = json_object_new_object(), *current_file = NULL; while( (dir_ent = readdir(dir_handle)) != NULL) { -- cgit 1.2.3-korg