From 195a03d84c59ff756bfb893b22f8f4ff2635ceb6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Bollo?= Date: Tue, 18 Sep 2018 11:03:23 +0200 Subject: [PATCH] afb-export: Emit a warning on bad 'afb_require_api' call MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/afb-export.c | 5 +++++ 1 file changed, 5 insertions(+) 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); -- 2.16.6