Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

error/success return values ignored in elektraGetDoUpdateWithGlobalHooks() #4044

Closed
qwepoizt opened this issue Sep 14, 2021 · 2 comments · Fixed by #4045
Closed

error/success return values ignored in elektraGetDoUpdateWithGlobalHooks() #4044

qwepoizt opened this issue Sep 14, 2021 · 2 comments · Fixed by #4045
Assignees

Comments

@qwepoizt
Copy link
Contributor

Problem

In several places of kdb.c return values from plugins' kdbGet() are ignored.

This leads to errors in these plugins from being ignored and not reported back to the initial caller of kdbGet().

Examples of ignored return values (list might be incomplete)

case FIRST:
keySetName (parentKey, keyName (initialParent));
elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, INIT);
elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, MAXONCE);
break;
case LAST:
keySetName (parentKey, keyName (initialParent));
elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, INIT);
elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, MAXONCE);
elektraGlobalError (handle, ks, parentKey, PROCGETSTORAGE, DEINIT);
break;

handle->globalPlugins[PROCGETSTORAGE][FOREACH]->kdbGet (handle->globalPlugins[PROCGETSTORAGE][FOREACH], ks,

handle->globalPlugins[POSTGETSTORAGE][FOREACH]->kdbGet (handle->globalPlugins[POSTGETSTORAGE][FOREACH], ks,

handle->globalPlugins[POSTGETCLEANUP][FOREACH]->kdbGet (handle->globalPlugins[POSTGETCLEANUP][FOREACH], ks,

elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, DEINIT);

Concrete example

One concrete example for the impact of the first example

case FIRST:
keySetName (parentKey, keyName (initialParent));
elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, INIT);
elektraGlobalGet (handle, ks, parentKey, GETSTORAGE, MAXONCE);
break;
case LAST:
keySetName (parentKey, keyName (initialParent));
elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, INIT);
elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, MAXONCE);
elektraGlobalError (handle, ks, parentKey, PROCGETSTORAGE, DEINIT);
break;

is that errors detected within elektraGoptsGet() are "swallowed".

E.g. opts.c detects a missing argument for a long option and returns false.

ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "Missing argument for long option: --%s",
keyBaseName (longOpt));
keyDel (longOpt);
return false;

This leads to the call to elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, MAXONCE); at:

elektraGlobalGet (handle, ks, parentKey, PROCGETSTORAGE, MAXONCE);

to fail.

However, the return value is ignored and thusly the error is ignored.

@qwepoizt
Copy link
Contributor Author

@markus2330 I've discovered this and am not sure if it is a bug or intended. What do you think?

@kodebach
Copy link
Member

Yes, this is a bug. All errors should be reported, at the very least as a warning (e.g. if there was already another error).

kodebach added a commit to kodebach/libelektra that referenced this issue Sep 14, 2021
@kodebach kodebach mentioned this issue Sep 14, 2021
20 tasks
tucek pushed a commit to tucek/libelektra that referenced this issue Sep 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants