From 487b8ac0f409240d84f4c6f4d1b83ca4b883ed55 Mon Sep 17 00:00:00 2001 From: Michael Zronek Date: Thu, 23 May 2019 16:57:49 +0200 Subject: [PATCH] error: recategorized errors, removed some TODOs --- src/libs/elektra/plugin.c | 4 +-- src/plugins/augeas/augeas.c | 4 +-- src/plugins/conditionals/conditionals.c | 24 ++++++++-------- src/plugins/crypto/openssl_operations.c | 6 ++-- src/plugins/curlget/curlget.c | 3 +- src/plugins/dump/dump.cpp | 5 ++-- src/plugins/gitresolver/gitresolver.c | 3 -- src/plugins/gpgme/gpgme.c | 4 +-- src/plugins/hexnumber/hexnumber.c | 4 --- src/plugins/iconv/iconv.c | 21 ++++++-------- src/plugins/ipaddr/ipaddr.c | 2 +- src/plugins/jni/jni.c | 16 +++++------ src/plugins/line/line.c | 3 +- src/plugins/multifile/multifile.c | 2 +- src/plugins/path/path.c | 3 +- src/plugins/quickdump/quickdump.c | 6 ++-- src/plugins/quickdump/readv1.c | 4 +-- src/plugins/resolver/filename.c | 38 ++++++++++++------------- src/plugins/resolver/resolver.c | 37 +++++++++++++----------- src/plugins/ruby/ruby.cpp | 2 +- src/plugins/specload/specload.c | 10 +++---- src/plugins/validation/validation.c | 5 ++-- src/plugins/xerces/xerces.cpp | 8 +++--- src/plugins/yambi/convert.cpp | 2 +- src/plugins/zeromqsend/zeromqsend.c | 2 +- 25 files changed, 103 insertions(+), 115 deletions(-) diff --git a/src/libs/elektra/plugin.c b/src/libs/elektra/plugin.c index bfc051e512a..26137705447 100644 --- a/src/libs/elektra/plugin.c +++ b/src/libs/elektra/plugin.c @@ -297,7 +297,7 @@ Plugin * elektraPluginOpen (const char * name, KeySet * modules, KeySet * config { if ((handle->kdbOpen (handle, errorKey)) == -1) { - ELEKTRA_ADD_INSTALLATION_WARNINGF ( + ELEKTRA_ADD_BROKEN_PLUGIN_WARNINGF ( errorKey, "Open of plugin returned unsuccessfully: %s. Reason contains plugin, see other warnings for details", name); elektraPluginClose (handle, errorKey); @@ -328,7 +328,7 @@ int elektraPluginClose (Plugin * handle, Key * errorKey) if (handle->kdbClose) { rc = handle->kdbClose (handle, errorKey); - if (rc == -1) ELEKTRA_ADD_INSTALLATION_WARNING (errorKey, "kdbClose() failed"); + if (rc == -1) ELEKTRA_ADD_GENERAL_RESOURCE_WARNING (errorKey, "kdbClose() failed"); } ksDel (handle->config); diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 936ab24c7e3..14c18129e92 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -432,7 +432,7 @@ int elektraAugeasOpen (Plugin * handle, Key * parentKey) if (ret >= 0) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Unable to allocate memory for a detailed augeas error message"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Unable to allocate memory for a detailed augeas error message"); return -1; } @@ -519,7 +519,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (!conversionData) { fclose (fh); - ELEKTRA_SET_INSTALLATION_ERRORF ( + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( parentKey, "Unknown or unsupported type found during streaming, assume key as string, type lost. Errno: %s", strerror (errno)); } diff --git a/src/plugins/conditionals/conditionals.c b/src/plugins/conditionals/conditionals.c index 5edf7287e1d..ac7b04235bd 100644 --- a/src/plugins/conditionals/conditionals.c +++ b/src/plugins/conditionals/conditionals.c @@ -209,7 +209,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp } if (elektraRealloc ((void **) &compareTo, endPos - rightSide) < 0) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -228,7 +228,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp if (elektraRealloc ((void **) &lookupName, len) < 0) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -253,7 +253,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp } if (elektraRealloc ((void **) &compareTo, keyGetValueSize (key)) < 0) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -269,7 +269,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp if (elektraRealloc ((void **) &lookupName, len) < 0) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); result = ERROR; goto Cleanup; } @@ -564,8 +564,8 @@ static CondResult parseCondition (Key * key, const char * condition, const Key * if ((regcomp (®ex, regexString, REG_EXTENDED | REG_NEWLINE))) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, + "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory ksDel (ks); @@ -619,8 +619,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList CondResult ret; if ((ret = regcomp (®ex1, regexString1, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, + "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory ksDel (ks); @@ -628,8 +628,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if ((ret = regcomp (®ex2, regexString2, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, + "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory regfree (®ex1); @@ -638,8 +638,8 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if ((ret = regcomp (®ex3, regexString3, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, + "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only // possible error would be out of // memory regfree (®ex1); diff --git a/src/plugins/crypto/openssl_operations.c b/src/plugins/crypto/openssl_operations.c index c701195d130..07b3ef89c7e 100644 --- a/src/plugins/crypto/openssl_operations.c +++ b/src/plugins/crypto/openssl_operations.c @@ -202,7 +202,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { keyDel (key); keyDel (iv); - ELEKTRA_SET_ASSERTION_ERROR (errorKey, "Failed to create handle! Invalid key length."); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Failed to create handle! Invalid key length."); return -1; } @@ -210,8 +210,8 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { keyDel (key); keyDel (iv); - // TODO: Correct? - ELEKTRA_SET_ASSERTION_ERROR (errorKey, "Failed to create handle! Invalid IV length."); + + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Failed to create handle! Invalid IV length."); return -1; } diff --git a/src/plugins/curlget/curlget.c b/src/plugins/curlget/curlget.c index 64137098275..f0bd479da7e 100644 --- a/src/plugins/curlget/curlget.c +++ b/src/plugins/curlget/curlget.c @@ -722,7 +722,6 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA ++(data->setPhase); if (strncmp ((char *) data->lastHash, (char *) hash, MD5_DIGEST_LENGTH)) { - // TODO: Correct? ELEKTRA_SET_CONFLICTING_STATE_ERROR (parentKey, "remote file has changed"); retval = -1; } @@ -734,7 +733,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA else { close (fd); - ELEKTRA_SET_GENERAL_RESOURCE_ERRORF ( + ELEKTRA_SET_CONFLICTING_STATE_ERRORF ( parentKey, "Failed to fetch configuration from %s. Aborting because consistency can't be ensured", data->getUrl); if (data->tmpFile) unlink (data->tmpFile); diff --git a/src/plugins/dump/dump.cpp b/src/plugins/dump/dump.cpp index 5c577d3b2e5..52c9cb4851f 100644 --- a/src/plugins/dump/dump.cpp +++ b/src/plugins/dump/dump.cpp @@ -115,8 +115,7 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks) ss >> version; if (version != "1") { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (errorKey, "Wrong version detected in dumpfile: %s", - version.c_str ()); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Wrong version detected in dumpfile: %s", version.c_str ()); return -1; } } @@ -189,7 +188,7 @@ int unserialise (std::istream & is, ckdb::Key * errorKey, ckdb::KeySet * ks) } else { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (errorKey, "Wrong version detected in dumpfile: %s", command.c_str ()); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Wrong version detected in dumpfile: %s", command.c_str ()); return -1; } } diff --git a/src/plugins/gitresolver/gitresolver.c b/src/plugins/gitresolver/gitresolver.c index 97509c22b20..4d25fbde2f1 100644 --- a/src/plugins/gitresolver/gitresolver.c +++ b/src/plugins/gitresolver/gitresolver.c @@ -662,7 +662,6 @@ int elektraGitresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE int rc = pullFromRemote (data, repo); if (rc) { - // TODO: Correct? ELEKTRA_SET_CONFLICTING_STATE_ERROR (parentKey, "Fast-forward pull failed, please pull manually\n"); git_repository_free (repo); git_libgit2_shutdown (); @@ -861,7 +860,6 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE if (newCommit) { // newer commit in repo - abort - // TODO: Correct? ELEKTRA_SET_CONFLICTING_STATE_ERROR (parentKey, "The repository has been updated and is ahead of you"); elektraFree (newCommit); git_reference_free (headRef); @@ -880,7 +878,6 @@ int elektraGitresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELE char * newObj = hasNewObjectCommit (data, blob); if (newObj) { - // TODO: Correct? ELEKTRA_SET_CONFLICTING_STATE_ERROR (parentKey, "The repository has been updated and is ahead of you"); elektraFree (newObj); git_object_free (blob); diff --git a/src/plugins/gpgme/gpgme.c b/src/plugins/gpgme/gpgme.c index 8b91becb21f..9e2556d0033 100644 --- a/src/plugins/gpgme/gpgme.c +++ b/src/plugins/gpgme/gpgme.c @@ -153,7 +153,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er err = gpgme_get_key (ctx, keyString (gpgRecipientRoot), &key, 0); if (err) { - // TODO: Correct? + // TODO: Correct?? ELEKTRA_SET_ASSERTION_ERRORF (errorKey, "Failed to receive the GPG key because: %s", gpgme_strerror (err)); elektraGpgmeKeylistFree (&list); return NULL; @@ -183,7 +183,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er err = gpgme_get_key (ctx, keyString (k), &key, 0); if (err) { - // TODO: Correct? + // TODO: Correct?? ELEKTRA_SET_ASSERTION_ERRORF (errorKey, "Failed to receive the GPG key because: %s", gpgme_strerror (err)); elektraGpgmeKeylistFree (&list); diff --git a/src/plugins/hexnumber/hexnumber.c b/src/plugins/hexnumber/hexnumber.c index 2aa92be30e2..0a7e0f61abc 100644 --- a/src/plugins/hexnumber/hexnumber.c +++ b/src/plugins/hexnumber/hexnumber.c @@ -83,7 +83,6 @@ static int convertHexToDec (Key * key, Key * parentKey) int result = snprintf (NULL, 0, "%llu", value); if (result < 0) { - // TODO: Correct? ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Unable to convert '%s' into decimal", hexValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -99,7 +98,6 @@ static int convertHexToDec (Key * key, Key * parentKey) result = snprintf (decValue, length, "%llu", value); if (result < 0) { - // TODO: Correct? ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Unable to convert '%s' into decimal", hexValue); elektraFree (decValue); return ELEKTRA_PLUGIN_STATUS_ERROR; @@ -154,7 +152,6 @@ static int convertDecToHex (Key * key, Key * parentKey) const int result = snprintf (NULL, 0, "0x%llx", value); if (result < 0) { - // TODO: Correct? ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Unable to convert '%s' into hexadecimal", decValue); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -169,7 +166,6 @@ static int convertDecToHex (Key * key, Key * parentKey) if (snprintf (hexValue, length, "0x%llx", value) < 0) { - // TODO: Correct? ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Unable to convert '%s' into hexadecimal", decValue); elektraFree (hexValue); return ELEKTRA_PLUGIN_STATUS_ERROR; diff --git a/src/plugins/iconv/iconv.c b/src/plugins/iconv/iconv.c index 872aab72aa3..86f8eea7645 100644 --- a/src/plugins/iconv/iconv.c +++ b/src/plugins/iconv/iconv.c @@ -197,8 +197,7 @@ int elektraIconvGet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (meta), keyGetValueSize (meta)); if (kdbbUTF8Engine (handle, UTF8_FROM, &convertedData, &convertedDataSize)) { - // TODO: Correct? - ELEKTRA_SET_INSTALLATION_ERRORF ( + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF ( parentKey, "Could not convert string %s, got result %s, encoding settings are from %s to %s", keyString (meta), convertedData, getFrom (handle), getTo (handle)); elektraFree (convertedData); @@ -231,11 +230,10 @@ int elektraIconvSet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (cur), keyGetValueSize (cur)); if (kdbbUTF8Engine (handle, UTF8_TO, &convertedData, &convertedDataSize)) { - // TODO: Correct? - ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, - "Could not convert string %s, got result %s," - " encoding settings are from %s to %s (but swapped for write)", - keyString (cur), convertedData, getFrom (handle), getTo (handle)); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, + "Could not convert string %s, got result %s," + " encoding settings are from %s to %s (but swapped for write)", + keyString (cur), convertedData, getFrom (handle), getTo (handle)); elektraFree (convertedData); return -1; } @@ -252,11 +250,10 @@ int elektraIconvSet (Plugin * handle, KeySet * returned, Key * parentKey) memcpy (convertedData, keyString (meta), keyGetValueSize (meta)); if (kdbbUTF8Engine (handle, UTF8_TO, &convertedData, &convertedDataSize)) { - // TODO: Correct? - ELEKTRA_SET_INSTALLATION_ERRORF (parentKey, - "Could not convert string %s, got result %s," - " encodings settings are from %s to %s (but swapped for write)", - keyString (meta), convertedData, getFrom (handle), getTo (handle)); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, + "Could not convert string %s, got result %s," + " encodings settings are from %s to %s (but swapped for write)", + keyString (meta), convertedData, getFrom (handle), getTo (handle)); elektraFree (convertedData); return -1; } diff --git a/src/plugins/ipaddr/ipaddr.c b/src/plugins/ipaddr/ipaddr.c index e7638d53e39..2adbccec6b8 100644 --- a/src/plugins/ipaddr/ipaddr.c +++ b/src/plugins/ipaddr/ipaddr.c @@ -107,7 +107,7 @@ static int validateKey (Key * key, Key * parentKey) } else if (rc == -1) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); rc = 0; } diff --git a/src/plugins/jni/jni.c b/src/plugins/jni/jni.c index 2a86760e22a..282f881f81d 100644 --- a/src/plugins/jni/jni.c +++ b/src/plugins/jni/jni.c @@ -234,56 +234,56 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) data->clsPlugin = (*data->env)->FindClass (data->env, classname); if (data->clsPlugin == 0) { - ELEKTRA_SET_INTERFACE_ERRORF (errorKey, "Cannot find class %s", classname); + ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (errorKey, "Cannot find class %s", classname); return -1; } data->clsKey = (*data->env)->FindClass (data->env, "org/libelektra/Key"); if (data->clsKey == 0) { - ELEKTRA_SET_INTERFACE_ERROR (errorKey, "Cannot find class Key"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (errorKey, "Cannot find class Key"); return -1; } data->clsKeySet = (*data->env)->FindClass (data->env, "org/libelektra/KeySet"); if (data->clsKeySet == 0) { - ELEKTRA_SET_INTERFACE_ERROR (errorKey, "Cannot find class KeySet"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (errorKey, "Cannot find class KeySet"); return -1; } data->midKeyConstr = (*data->env)->GetMethodID (data->env, data->clsKey, "", "(J)V"); if (data->midKeyConstr == 0) { - ELEKTRA_SET_INTERFACE_ERROR (errorKey, "Cannot find constructor of Key"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (errorKey, "Cannot find constructor of Key"); return -1; } data->midKeySetConstr = (*data->env)->GetMethodID (data->env, data->clsKeySet, "", "(J)V"); if (data->midKeySetConstr == 0) { - ELEKTRA_SET_INTERFACE_ERROR (errorKey, "Cannot find constructor of KeySet"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (errorKey, "Cannot find constructor of KeySet"); return -1; } data->midKeyRelease = (*data->env)->GetMethodID (data->env, data->clsKey, "release", "()V"); if (data->midKeyRelease == 0) { - ELEKTRA_SET_INTERFACE_ERROR (errorKey, "Cannot find release of Key"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (errorKey, "Cannot find release of Key"); return -1; } data->midKeySetRelease = (*data->env)->GetMethodID (data->env, data->clsKeySet, "release", "()V"); if (data->midKeySetRelease == 0) { - ELEKTRA_SET_INTERFACE_ERROR (errorKey, "Cannot find release of KeySet"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (errorKey, "Cannot find release of KeySet"); return -1; } jmethodID midPluginConstructor = (*data->env)->GetMethodID (data->env, data->clsPlugin, "", "()V"); if (midPluginConstructor == 0) { - ELEKTRA_SET_INTERFACE_ERROR (errorKey, "Cannot find constructor of plugin"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (errorKey, "Cannot find constructor of plugin"); return -1; } diff --git a/src/plugins/line/line.c b/src/plugins/line/line.c index 6634b174b05..07bdb4f21f9 100644 --- a/src/plugins/line/line.c +++ b/src/plugins/line/line.c @@ -100,8 +100,7 @@ int elektraLineGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * par if (ret == -1) { - // TODO: Correct? - ELEKTRA_SET_ASSERTION_ERRORF (parentKey, "could not increment array from %s", keyName (ksTail (returned))); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "could not increment array from %s", keyName (ksTail (returned))); ret = -1; } else if (feof (fp) == 0) diff --git a/src/plugins/multifile/multifile.c b/src/plugins/multifile/multifile.c index bb586efe2fb..cde78d5130f 100644 --- a/src/plugins/multifile/multifile.c +++ b/src/plugins/multifile/multifile.c @@ -407,7 +407,7 @@ static Codes updateFilesGlob (Plugin * handle, MultiConfig * mc, KeySet * found, { if (ret == GLOB_NOSPACE) { - ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "glob(%s) ran out of memory", pattern); + ELEKTRA_SET_OUT_OF_MEMORY_ERRORF (parentKey, "glob(%s) ran out of memory", pattern); } else if (ret == GLOB_ABORTED) { diff --git a/src/plugins/path/path.c b/src/plugins/path/path.c index ba85ba0e6db..612ee6c0ddb 100644 --- a/src/plugins/path/path.c +++ b/src/plugins/path/path.c @@ -59,7 +59,7 @@ static int validateKey (Key * key, Key * parentKey) } else if (keyString (key)[0] != '/') { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Given path \"%s\" is not absolute", keyString (key)); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Given path \"%s\" is not absolute", keyString (key)); return 0; } int errnosave = errno; @@ -211,6 +211,7 @@ static int validatePermission (Key * key, Key * parentKey) if (canAccess != 0) { + // No Resource error per se because related to the specification check! ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "User %s does not have required permission (%s) on %s", name, modes, validPath); return -1; diff --git a/src/plugins/quickdump/quickdump.c b/src/plugins/quickdump/quickdump.c index 7ae65ed7554..dbf596c5b50 100644 --- a/src/plugins/quickdump/quickdump.c +++ b/src/plugins/quickdump/quickdump.c @@ -386,8 +386,8 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key const Key * sourceKey = ksLookupByName (returned, nameBuffer.string, 0); if (sourceKey == NULL) { - ELEKTRA_SET_ASSERTION_ERRORF (parentKey, "Could not copy meta data from key '%s': Key not found", - nameBuffer.string); + ELEKTRA_SET_GENERAL_RESOURCE_ERRORF ( + parentKey, "Could not copy meta data from key '%s': Key not found", nameBuffer.string); keyDel (k); elektraFree (nameBuffer.string); elektraFree (metaNameBuffer.string); @@ -416,7 +416,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key elektraFree (metaNameBuffer.string); elektraFree (valueBuffer.string); fclose (file); - ELEKTRA_SET_BROKEN_PLUGIN_ERRORF (parentKey, "Unknown meta type %c", type); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Unknown meta type %c", type); return ELEKTRA_PLUGIN_STATUS_ERROR; } } diff --git a/src/plugins/quickdump/readv1.c b/src/plugins/quickdump/readv1.c index eb9ff849b81..6ca4fab4c1d 100644 --- a/src/plugins/quickdump/readv1.c +++ b/src/plugins/quickdump/readv1.c @@ -145,8 +145,8 @@ static int readVersion1 (FILE * file, KeySet * returned, Key * parentKey) const Key * sourceKey = ksLookupByName (returned, keyName, 0); if (sourceKey == NULL) { - ELEKTRA_SET_ASSERTION_ERRORF (parentKey, "Could not copy meta data from key '%s': Key not found", - keyName); + ELEKTRA_SET_GENERAL_RESOURCE_ERRORF ( + parentKey, "Could not copy meta data from key '%s': Key not found", keyName); keyDel (k); elektraFree (keyName); elektraFree (metaName); diff --git a/src/plugins/resolver/filename.c b/src/plugins/resolver/filename.c index d1e7845f6b8..5899393b4f8 100644 --- a/src/plugins/resolver/filename.c +++ b/src/plugins/resolver/filename.c @@ -144,7 +144,6 @@ static char * elektraResolvePasswd (Key * warningsKey) elektraFree (buf); if (s != 0) { - // TODO: Correct? ELEKTRA_ADD_INSTALLATION_WARNINGF (warningsKey, "Could not retrieve from passwd using getpwuid_r: %s", strerror (s)); } @@ -187,12 +186,11 @@ static int elektraResolveUserXDGHome (ElektraResolved * handle, Key * warningsKe if (home[0] != '/') { - // TODO: Correct? - ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNINGF (warningsKey, - "XDG_CONFIG_HOME contains a path that is " - "not absolute (violates XDG specification) and thus " - "it was skipped: %s", - home); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (warningsKey, + "XDG_CONFIG_HOME contains a path that is " + "not absolute (violates XDG specification) and thus " + "it was skipped: %s", + home); return 0; } elektraResolveUsingHome (handle, home, 0); @@ -210,11 +208,11 @@ static int elektraResolveEnvHome (ElektraResolved * handle, Key * warningsKey) if (home[0] != '/') { - ELEKTRA_ADD_VALIDATION_SEMANTIC_WARNINGF (warningsKey, - "HOME contains a path that is " - "not absolute and thus " - "it was skipped: %s", - home); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (warningsKey, + "HOME contains a path that is " + "not absolute and thus " + "it was skipped: %s", + home); return 0; } elektraResolveUsingHome (handle, home, 1); @@ -385,11 +383,11 @@ static int elektraResolveSystemXDG (ElektraResolved * handle, ElektraResolveTemp { if (result[0] != '/') { - ELEKTRA_ADD_INSTALLATION_WARNINGF (warningsKey, - "XDG_CONFIG_DIRS contains a path that is " - "not absolute (violates XDG specification) and thus " - "it was skipped: %s", - result); + ELEKTRA_ADD_VALIDATION_SYNTACTIC_WARNINGF (warningsKey, + "XDG_CONFIG_DIRS contains a path that is " + "not absolute (violates XDG specification) and thus " + "it was skipped: %s", + result); result = strtok_r (0, ":", &saveptr); continue; @@ -488,7 +486,7 @@ static char * elektraGetCwd (Key * warningsKey) char * cwd = elektraMalloc (size); if (cwd == NULL) { - ELEKTRA_ADD_GENERAL_RESOURCE_WARNING (warningsKey, "could not alloc for getcwd, defaulting to /"); + ELEKTRA_ADD_OUT_OF_MEMORY_WARNING (warningsKey, "could not alloc for getcwd, defaulting to /"); return 0; } @@ -513,8 +511,8 @@ static char * elektraGetCwd (Key * warningsKey) elektraRealloc ((void **) &cwd, size); if (cwd == NULL) { - ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (warningsKey, "could not realloc for getcwd size %d, defaulting to /", - size); + ELEKTRA_ADD_OUT_OF_MEMORY_WARNINGF (warningsKey, "could not realloc for getcwd size %d, defaulting to /", + size); return 0; } } diff --git a/src/plugins/resolver/resolver.c b/src/plugins/resolver/resolver.c index 99010a0bf81..66c8e48069d 100644 --- a/src/plugins/resolver/resolver.c +++ b/src/plugins/resolver/resolver.c @@ -150,13 +150,13 @@ static int elektraLockFile (int fd ELEKTRA_UNUSED, Key * parentKey ELEKTRA_UNUSE { if (errno == EAGAIN || errno == EACCES) { - ELEKTRA_SET_CONFLICTING_STATE_ERROR ( + ELEKTRA_SET_GENERAL_RESOURCE_ERROR ( parentKey, "conflict because other process writes to configuration indicated by file lock"); } else { - ELEKTRA_SET_CONFLICTING_STATE_ERRORF (parentKey, "assuming conflict because of failed file lock with message: %s", - strerror (errno)); + ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "assuming conflict because of failed file lock with message: %s", + strerror (errno)); } return -1; } @@ -664,10 +664,10 @@ static int elektraOpenFile (resolverHandle * pk, Key * parentKey) { if (errno == ENOENT) { - ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, - "The configuration file \"%s\" was there earlier, " - "now it is missing", - pk->filename); + ELEKTRA_SET_ASSERTION_ERRORF (parentKey, + "The configuration file \"%s\" was there earlier, " + "now it is missing", + pk->filename); return -1; } else if (pk->fd == -1) @@ -689,10 +689,10 @@ static int elektraOpenFile (resolverHandle * pk, Key * parentKey) } else if (errno == EEXIST) { - ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, - "No configuration file was there earlier, " - "now configuration file \"%s\" exists", - pk->filename); + ELEKTRA_SET_ASSERTION_ERRORF (parentKey, + "No configuration file was there earlier, " + "now configuration file \"%s\" exists", + pk->filename); return -1; } @@ -842,7 +842,7 @@ static int elektraCheckConflict (resolverHandle * pk, Key * parentKey) ELEKTRA_ADD_GENERAL_RESOURCE_WARNING (parentKey, errorText); elektraFree (errorText); - ELEKTRA_SET_CONFLICTING_STATE_ERROR (parentKey, "assuming conflict because of failed stat (warning 29 for details)"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "assuming conflict because of failed stat (warning 29 for details)"); return -1; } @@ -1062,8 +1062,9 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) // change mode to what it was before if (fchmod (fd, pk->filemode) == -1) { - ELEKTRA_ADD_ASSERTION_WARNINGF (parentKey, "Could not fchmod temporary file \"%s\" from %o to %o, because %s", - pk->tempfile, buf.st_mode, pk->filemode, strerror (errno)); + ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (parentKey, + "Could not fchmod temporary file \"%s\" from %o to %o, because %s", + pk->tempfile, buf.st_mode, pk->filemode, strerror (errno)); } } @@ -1071,8 +1072,9 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) { if (fchown (fd, pk->uid, pk->gid) == -1) { - ELEKTRA_ADD_ASSERTION_WARNINGF (parentKey, "Could not fchown temporary file \"%s\" from %d.%d to %d.%d, because %s", - pk->tempfile, buf.st_uid, buf.st_gid, pk->uid, pk->gid, strerror (errno)); + ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (parentKey, + "Could not fchown temporary file \"%s\" from %d.%d to %d.%d, because %s", + pk->tempfile, buf.st_uid, buf.st_gid, pk->uid, pk->gid, strerror (errno)); } } @@ -1083,7 +1085,8 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey) // checking dirp not needed, fsync will have EBADF if (fsync (dirfd (dirp)) == -1) { - ELEKTRA_ADD_INSTALLATION_WARNINGF (parentKey, "Could not sync directory \"%s\", because %s", pk->dirname, strerror (errno)); + ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (parentKey, "Could not sync directory \"%s\", because %s", pk->dirname, + strerror (errno)); } closedir (dirp); diff --git a/src/plugins/ruby/ruby.cpp b/src/plugins/ruby/ruby.cpp index ca90b3d202a..cfe432c2e04 100644 --- a/src/plugins/ruby/ruby.cpp +++ b/src/plugins/ruby/ruby.cpp @@ -652,7 +652,7 @@ int RUBY_PLUGIN_FUNCTION (Get) (ckdb::Plugin * handle, ckdb::KeySet * returned, else { /* if not 'get' method is available, this plugin is useless, therefore set and error */ - ELEKTRA_SET_BROKEN_PLUGIN_ERROR (parentKey, "plugin does not have a 'get' method"); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "plugin does not have a 'get' method"); return -1; } return -1; diff --git a/src/plugins/specload/specload.c b/src/plugins/specload/specload.c index 383e1912350..639f19c54f2 100644 --- a/src/plugins/specload/specload.c +++ b/src/plugins/specload/specload.c @@ -180,7 +180,7 @@ int elektraSpecloadGet (Plugin * handle, KeySet * returned, Key * parentKey) if (keyGetNamespace (parentKey) != KEY_NS_SPEC) { - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "This plugin can only be used for the spec namespace."); + ELEKTRA_SET_INTERFACE_ERROR (parentKey, "This plugin can only be used for the spec namespace."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -211,7 +211,7 @@ int elektraSpecloadGet (Plugin * handle, KeySet * returned, Key * parentKey) if (elektraInvoke2Args (specload->quickDump, "set", ks, parentKey) == ELEKTRA_PLUGIN_STATUS_ERROR) { ksDel (ks); - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "Couldn't create an empty overlay specification."); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Couldn't create an empty overlay specification."); return ELEKTRA_PLUGIN_STATUS_ERROR; } ksDel (ks); @@ -227,7 +227,7 @@ int elektraSpecloadSet (Plugin * handle, KeySet * returned, Key * parentKey) { if (keyGetNamespace (parentKey) != KEY_NS_SPEC) { - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "This plugin can only be used for the spec namespace."); + ELEKTRA_SET_INTERFACE_ERROR (parentKey, "This plugin can only be used for the spec namespace."); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -281,7 +281,7 @@ int elektraSpecloadSet (Plugin * handle, KeySet * returned, Key * parentKey) if (changeAllowed < 0) { - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "This kind of change is not allowed."); + ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "This kind of change is not allowed."); ksSetCursor (returned, cursor); ksDel (overrides); ksDel (oldData); @@ -363,7 +363,7 @@ bool getAppAndArgs (KeySet * conf, char ** appPtr, char *** argvPtr, Key * error if (app[0] != '/') { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "The value of the app config key ('%s') is not an absolute path.", app); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (errorKey, "The value of the app config key ('%s') is not an absolute path.", app); return false; } diff --git a/src/plugins/validation/validation.c b/src/plugins/validation/validation.c index dce16310080..57f83fcb546 100644 --- a/src/plugins/validation/validation.c +++ b/src/plugins/validation/validation.c @@ -111,7 +111,6 @@ static int validateKey (Key * key, Key * parentKey) { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - // TODO: Correct? ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Could not compile regex: %s", buffer); regfree (®ex); if (freeString) elektraFree (regexString); @@ -146,7 +145,7 @@ static int validateKey (Key * key, Key * parentKey) const Key * msg = keyGetMeta (key, "check/validation/message"); if (msg) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Key value failed to validate: %s", keyString (msg)); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Key value failed to validate: %s", keyString (msg)); regfree (®ex); if (freeString) elektraFree (regexString); return 0; @@ -155,7 +154,7 @@ static int validateKey (Key * key, Key * parentKey) { char buffer[1000]; regerror (ret, ®ex, buffer, 999); - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Key value failed to validate: %s", buffer); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Key value failed to validate: %s", buffer); regfree (®ex); if (freeString) elektraFree (regexString); return 0; diff --git a/src/plugins/xerces/xerces.cpp b/src/plugins/xerces/xerces.cpp index 331f57199a5..59832d5837d 100644 --- a/src/plugins/xerces/xerces.cpp +++ b/src/plugins/xerces/xerces.cpp @@ -65,7 +65,7 @@ int elektraXercesGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (const OutOfMemoryException & e) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, asCStr (e.getMessage ())); } catch (const XMLException & e) { @@ -81,7 +81,7 @@ int elektraXercesGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (...) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (parentKey, "Unknown exception occurred while reading xml file"); + ELEKTRA_SET_ASSERTION_ERROR (parentKey, "Unknown exception occurred while reading xml file"); } // Avoid destruction of the pointers at the end @@ -103,7 +103,7 @@ int elektraXercesSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (const OutOfMemoryException & e) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, asCStr (e.getMessage ())); } catch (const XMLException & e) { @@ -119,7 +119,7 @@ int elektraXercesSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (...) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (parentKey, "Unknown exception occurred while writing xml file"); + ELEKTRA_SET_ASSERTION_ERROR (parentKey, "Unknown exception occurred while writing xml file"); } // Avoid destruction of the pointers at the end diff --git a/src/plugins/yambi/convert.cpp b/src/plugins/yambi/convert.cpp index 36f094ee065..3af66665166 100644 --- a/src/plugins/yambi/convert.cpp +++ b/src/plugins/yambi/convert.cpp @@ -50,7 +50,7 @@ int addToKeySet (CppKeySet & keySet, CppKey & parent, string const & filename) } else if (status == -2) { - ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parent.getKey (), "Parsing failed due to memory exhaustion"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent.getKey (), "Parsing failed due to memory exhaustion"); } else if (status == -1) { diff --git a/src/plugins/zeromqsend/zeromqsend.c b/src/plugins/zeromqsend/zeromqsend.c index 8e1ceceb782..df5c3edd5ee 100644 --- a/src/plugins/zeromqsend/zeromqsend.c +++ b/src/plugins/zeromqsend/zeromqsend.c @@ -113,7 +113,7 @@ int elektraZeroMqSendSet (Plugin * handle, KeySet * returned ELEKTRA_UNUSED, Key break; case -1: // connection timeout - hub not running - ELEKTRA_ADD_TIMEOUT_WARNING (parentKey, "could not connect to hub. Please start hub using `kdb run-hub-zeromq`."); + ELEKTRA_ADD_INSTALLATION_WARNING (parentKey, "could not connect to hub. Please start hub using `kdb run-hub-zeromq`."); break; case -2: // subscription timeout - no applications are listening for notifications, can be ignored