summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-09-18 11:03:23 +0200
committerJose Bollo <jose.bollo@iot.bzh>2018-09-24 10:05:00 +0200
commit195a03d84c59ff756bfb893b22f8f4ff2635ceb6 (patch)
treea456cc7eb52a5a2422aa3fab085a766e4f49602b
parentefd6d20aee652b5868090e11504a7ba163a09ee3 (diff)
afb-export: Emit a warning on bad 'afb_require_api' callguppy_6.90.0guppy/6.90.06.90.0
The call to 'afb_require_api' in a preinit was forbiden before binding v3 refactoring. Since v3 it is made possible by deferring the requirement to the initialisation step. But this may lead to bad behaviour if someone use the call to test whether an api exists or not. This commit introduce a message that could warn a developper raising that issue. Change-Id: Icc14c3887d70f73d87da0e664bb0e5e961867b4a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-export.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/afb-export.c b/src/afb-export.c
index e679b769..fdd4573f 100644
--- a/src/afb-export.c
+++ b/src/afb-export.c
@@ -352,6 +352,11 @@ static int require_api_cb(struct afb_api_x3 *closure, const char *name, int init
int rc, rc2;
char *iter, *end, save;
+ /* emit a warning about unexpected require in preinit */
+ if (export->state == Api_State_Pre_Init)
+ WARNING("[API %s] requiring apis in pre-init may lead to unexpected result (requires%s: %s)",
+ export->api.apiname, initialized ? " initialized" : "", name);
+
/* scan the names in a local copy */
rc = 0;
iter = strdupa(name);