From 8f4da8abb5124d5cf97bc4151d93f32e5e552f70 Mon Sep 17 00:00:00 2001 From: Michael Zronek Date: Sun, 23 Jun 2019 22:15:09 +0200 Subject: [PATCH] error: Improvements part 7 --- src/include/kdbmacros.h | 4 ++-- src/plugins/augeas/augeas.c | 6 +++--- src/plugins/blockresolver/blockresolver.c | 2 +- src/plugins/boolean/boolean.c | 2 +- src/plugins/cache/cache.c | 2 +- src/plugins/cachefilter/cachefilter.c | 2 +- src/plugins/crypto/botan_operations.cpp | 12 ++++++------ src/plugins/crypto/gcrypt_operations.c | 12 ++++++------ src/plugins/crypto/gpg.c | 14 +++++++------- src/plugins/crypto/openssl_operations.c | 8 ++++---- src/plugins/curlget/curlget.c | 12 ++++++------ src/plugins/date/date.c | 10 +++++----- src/plugins/enum/enum.c | 2 +- src/plugins/fcrypt/fcrypt.c | 10 +++++----- src/plugins/gpgme/gpgme.c | 14 +++++++------- src/plugins/hexnumber/hexnumber.c | 2 +- src/plugins/hosts/hosts-get.c | 2 +- src/plugins/ipaddr/ipaddr.c | 2 +- src/plugins/jni/jni.c | 4 ++-- src/plugins/macaddr/macaddr.c | 2 +- src/plugins/mathcheck/mathcheck.c | 12 ++++++------ src/plugins/network/network.c | 6 +++--- src/plugins/path/path.c | 2 +- 23 files changed, 72 insertions(+), 72 deletions(-) diff --git a/src/include/kdbmacros.h b/src/include/kdbmacros.h index 70b45a765e1..43349697f24 100644 --- a/src/include/kdbmacros.h +++ b/src/include/kdbmacros.h @@ -57,11 +57,11 @@ "root. Errno: %s", \ keyString (parentKey), strerror (errno)); \ else \ - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open file %s for writing %s", keyString (parentKey), \ + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open file %s for writing. Reason: %s", keyString (parentKey), \ strerror (errno)); \ } while (0) -#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_OUT_OF_MEMORY_ERRORF (key, "Unable to allocate %zu bytes.", size); +#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_OUT_OF_MEMORY_ERRORF (key, "Unable to allocate %zu bytes", size); /** * @brief Sets error if info != returned diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 2b5f5765b89..8985ee2b37f 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -494,7 +494,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (content == 0) { fclose (fh); - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file. Reason: %s", strerror (errno)); } /* convert the string into an augeas tree */ @@ -576,7 +576,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) if (content == 0) { fclose (fh); - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Error while reading file. Reason: %s", strerror (errno)); } /* convert the string into an augeas tree */ @@ -603,7 +603,7 @@ int elektraAugeasSet (Plugin * handle, KeySet * returned, Key * parentKey) ret = saveFile (augeasHandle, fh); fclose (fh); - if (ret < 0) ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open file for writing: %s", strerror (errno)); + if (ret < 0) ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open file for writing. Reason: %s", strerror (errno)); errno = errnosave; return 1; diff --git a/src/plugins/blockresolver/blockresolver.c b/src/plugins/blockresolver/blockresolver.c index 351d7372499..40287bf4aaa 100644 --- a/src/plugins/blockresolver/blockresolver.c +++ b/src/plugins/blockresolver/blockresolver.c @@ -317,7 +317,7 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E } if (buf.st_mtime > data->mtime) { - ELEKTRA_SET_CONFLICTING_STATE_ERRORF (parentKey, "%s has been modified", data->realFile); + ELEKTRA_SET_CONFLICTING_STATE_ERRORF (parentKey, "File '%s' has been modified", data->realFile); return -1; } FILE * fout = NULL; diff --git a/src/plugins/boolean/boolean.c b/src/plugins/boolean/boolean.c index 35a3d43a97b..6d66d7219f3 100644 --- a/src/plugins/boolean/boolean.c +++ b/src/plugins/boolean/boolean.c @@ -343,7 +343,7 @@ int elektraBooleanSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA (keyGetMeta (key, "boolean/invalid"))) { keySetMeta (key, "boolean/invalid", 0); - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s is not a valid boolean value", + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "String '%s' is not a valid boolean value", keyString (originalValue)); retVal = -1; } diff --git a/src/plugins/cache/cache.c b/src/plugins/cache/cache.c index d44d59ce9c6..5dccdfb75d2 100644 --- a/src/plugins/cache/cache.c +++ b/src/plugins/cache/cache.c @@ -323,7 +323,7 @@ int elektraCacheSet (Plugin * handle, KeySet * returned, Key * parentKey) { if (rename (tmpFile, cacheFileName) == -1) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not rename file. Errno: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not rename file. Reason: %s", strerror (errno)); goto error; } diff --git a/src/plugins/cachefilter/cachefilter.c b/src/plugins/cachefilter/cachefilter.c index 57989020b62..f1e4345f447 100644 --- a/src/plugins/cachefilter/cachefilter.c +++ b/src/plugins/cachefilter/cachefilter.c @@ -79,7 +79,7 @@ int elektraCachefilterSet (Plugin * handle, KeySet * returned, Key * parentKey) if (cache == NULL) { // TODO: Solution (Call kdbGet() to initialize Cache) - ELEKTRA_SET_INTERFACE_ERROR (parentKey, "Cache was not initialized."); + ELEKTRA_SET_INTERFACE_ERROR (parentKey, "Cache was not initialized"); return -1; // did not call kdbGet() before and therefore // also no elektraCachefilterGet() } diff --git a/src/plugins/crypto/botan_operations.cpp b/src/plugins/crypto/botan_operations.cpp index 3690946960b..0aee67fadda 100644 --- a/src/plugins/crypto/botan_operations.cpp +++ b/src/plugins/crypto/botan_operations.cpp @@ -89,7 +89,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } catch (std::exception const & e) { - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to create a cryptographic key for encryption because: %s", e.what ()); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to create a cryptographic key for encryption. Reason: %s", e.what ()); return -1; } } @@ -139,7 +139,7 @@ static int getKeyIvForDecryption (KeySet * config, Key * errorKey, Key * masterK } catch (std::exception const & e) { - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to restore the cryptographic key for decryption because: %s", e.what ()); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to restore the cryptographic key for decryption. Reason: %s", e.what ()); return -1; } } @@ -152,7 +152,7 @@ int elektraCryptoBotanInit (Key * errorKey) } catch (std::exception const & e) { - ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERRORF (errorKey, "Botan initialization failed: %s", e.what ()); + ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERRORF (errorKey, "Botan initialization failed. Reason: %s", e.what ()); return -1; // failure } return 1; // success @@ -236,7 +236,7 @@ int elektraCryptoBotanEncrypt (KeySet * pluginConfig, Key * k, Key * errorKey, K } catch (std::exception const & e) { - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Encryption failed because: %s", e.what ()); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Encryption failed. Reason: %s", e.what ()); elektraFree (salt); return -1; // failure } @@ -308,7 +308,7 @@ int elektraCryptoBotanDecrypt (KeySet * pluginConfig, Key * k, Key * errorKey, K } catch (std::exception const & e) { - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Decryption failed because: %s", e.what ()); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Decryption failed. Reason: %s", e.what ()); return -1; // failure } @@ -338,7 +338,7 @@ char * elektraCryptoBotanCreateRandomString (Key * errorKey, const kdb_unsigned_ } catch (std::exception const & e) { - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to generate random string because: %s", e.what ()); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to generate random string. Reason: %s", e.what ()); return 0; } } diff --git a/src/plugins/crypto/gcrypt_operations.c b/src/plugins/crypto/gcrypt_operations.c index 9dd820a2dce..6f4b64720cd 100644 --- a/src/plugins/crypto/gcrypt_operations.c +++ b/src/plugins/crypto/gcrypt_operations.c @@ -71,7 +71,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK if ((gcry_err = gcry_kdf_derive (keyValue (masterKey), keyGetValueSize (masterKey), GCRY_KDF_PBKDF2, GCRY_MD_SHA512, salt, sizeof (salt), iterations, KEY_BUFFER_SIZE, keyBuffer))) { - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to create a cryptographic key for encryption because: %s", + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to create a cryptographic key for encryption. Reason: %s", gcry_strerror (gcry_err)); return -1; } @@ -114,7 +114,7 @@ static int getKeyIvForDecryption (KeySet * config, Key * errorKey, Key * masterK if ((gcry_err = gcry_kdf_derive (keyValue (masterKey), keyGetValueSize (masterKey), GCRY_KDF_PBKDF2, GCRY_MD_SHA512, saltBuffer, saltBufferLen, iterations, KEY_BUFFER_SIZE, keyBuffer))) { - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to restore the cryptographic key for decryption because: %s", + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to restore the cryptographic key for decryption. Reason: %s", gcry_strerror (gcry_err)); return -1; } @@ -234,7 +234,7 @@ int elektraCryptoGcryHandleCreate (elektraCryptoHandle ** handle, KeySet * confi memset (keyBuffer, 0, sizeof (keyBuffer)); memset (ivBuffer, 0, sizeof (ivBuffer)); // TODO: Correct?? - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to create handle because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to create handle. Reason: %s", gcry_strerror (gcry_err)); gcry_cipher_close (**handle); elektraFree (*handle); (*handle) = NULL; @@ -318,7 +318,7 @@ int elektraCryptoGcryEncrypt (elektraCryptoHandle * handle, Key * k, Key * error if (gcry_err != 0) { // TODO: Correct?? - ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Encryption failed. Reason: %s", gcry_strerror (gcry_err)); memset (output, 0, outputLen); elektraFree (output); elektraFree (salt); @@ -334,7 +334,7 @@ int elektraCryptoGcryEncrypt (elektraCryptoHandle * handle, Key * k, Key * error if (gcry_err != 0) { // TODO: Correct?? - ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Encryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Encryption failed. Reason: %s", gcry_strerror (gcry_err)); memset (output, 0, outputLen); elektraFree (output); elektraFree (salt); @@ -389,7 +389,7 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error gcry_err = gcry_cipher_decrypt (*handle, output, payloadLen, NULL, 0); if (gcry_err != 0) { - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Decryption failed because: %s", gcry_strerror (gcry_err)); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Decryption failed. Reason: %s", gcry_strerror (gcry_err)); memset (output, 0, payloadLen); elektraFree (output); return -1; diff --git a/src/plugins/crypto/gpg.c b/src/plugins/crypto/gpg.c index 9243496fa36..cd98525a414 100644 --- a/src/plugins/crypto/gpg.c +++ b/src/plugins/crypto/gpg.c @@ -256,7 +256,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgGetBinary) (char ** gpgBin, KeySet * conf, Key * } // no GPG for us :-( - ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "No gpg binary found. Please make sure GnuPG is installed and executable."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "No gpg binary found. Please make sure GnuPG is installed and executable"); return -1; } @@ -658,7 +658,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK { case -1: // fork() failed - ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Fork failed with errno: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Fork failed. Reason: %s", strerror (errno)); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); @@ -718,7 +718,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK { if (write (pipe_stdin[1], keyValue (msgKey), sendMessageSize) != sendMessageSize) { - ELEKTRA_SET_RESOURCE_ERROR (errorKey, "The communication with the GPG process failed."); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "The communication with the GPG process failed"); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); @@ -748,19 +748,19 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK case 1: // bad signature - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "GPG reported a bad signature. errno: %s", strerror (errno)); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "GPG reported a bad signature. Reason: %s", strerror (errno)); break; case GPG_CALL_DUP_STDIN: - ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Failed to redirect stdin."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Failed to redirect stdin"); break; case GPG_CALL_DUP_STDOUT: - ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Failed to redirect stdout."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Failed to redirect stdout"); break; case GPG_CALL_DUP_STDERR: - ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Failed to redirect stderr."); + ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Failed to redirect stderr"); break; case GPG_CALL_EXECV: diff --git a/src/plugins/crypto/openssl_operations.c b/src/plugins/crypto/openssl_operations.c index 9a06ff932ae..fd5f4a6f0af 100644 --- a/src/plugins/crypto/openssl_operations.c +++ b/src/plugins/crypto/openssl_operations.c @@ -199,7 +199,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { keyDel (key); keyDel (iv); - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Failed to create handle! Invalid key length."); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Failed to create handle! Invalid key length"); return -1; } @@ -208,7 +208,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co keyDel (key); keyDel (iv); - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Failed to create handle! Invalid IV length."); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Failed to create handle! Invalid IV length"); return -1; } @@ -468,7 +468,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er plaintextLen = BIO_get_mem_data (decrypted, &plaintext); if (plaintextLen < headerLen) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Decryption error! header data is incomplete."); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Decryption error! header data is incomplete"); goto error; } @@ -482,7 +482,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er if (contentLen > (plaintextLen - headerLen)) { ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR ( - errorKey, "Content length is bigger than amount of decrypted data. Data is possibly corrupted."); + errorKey, "Content length is bigger than amount of decrypted data. Data is possibly corrupted"); goto error; } diff --git a/src/plugins/curlget/curlget.c b/src/plugins/curlget/curlget.c index 3ea3b61b27a..70f8567b9a1 100644 --- a/src/plugins/curlget/curlget.c +++ b/src/plugins/curlget/curlget.c @@ -833,7 +833,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (HTTP PUT) failed: %s", + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (HTTP PUT) failed. Reason: %s", curl_easy_strerror (res)); retval = -1; } @@ -846,7 +846,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (HTTP PUT) failed: %s", + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (HTTP PUT) failed. Reason: %s", curl_easy_strerror (res)); retval = -1; } @@ -883,7 +883,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (FTP PUT) failed: %s", + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (FTP PUT) failed. Reason: %s", curl_easy_strerror (res)); retval = -1; } @@ -909,10 +909,10 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA if (res != CURLE_OK) { if (data->putProto == PROTO_SCP) - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (SCP) failed: %s", + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (SCP) failed. Reason: %s", curl_easy_strerror (res)); else if (data->putProto == PROTO_SFTP) - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (SFTP) failed: %s", + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (SFTP) failed. Reason: %s", curl_easy_strerror (res)); retval = -1; } @@ -929,7 +929,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA res = curl_easy_perform (curl); if (res != CURLE_OK) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (default) failed: %s", + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Curl upload (default) . Reason: %s", curl_easy_strerror (res)); retval = -1; } diff --git a/src/plugins/date/date.c b/src/plugins/date/date.c index 4376e964fd0..67baadf417a 100644 --- a/src/plugins/date/date.c +++ b/src/plugins/date/date.c @@ -411,7 +411,7 @@ static int validateKey (Key * key, Key * parentKey) rc = formatStringValidation (date, formatString); if (rc == -1) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "%s doesn't match format string %s", date, formatString); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Date '%s' doesn't match format string %s", date, formatString); rc = 0; } } @@ -421,10 +421,10 @@ static int validateKey (Key * key, Key * parentKey) if (rc == -1) { if (formatString) - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "%s doesn't match iso specification %s", date, + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Date '%s' doesn't match iso specification %s", date, formatString); else - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "%s is not a valid ISO8601 date", date); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Date '%s' is not a valid ISO8601 date", date); rc = 0; } else if (rc == 0) @@ -437,7 +437,7 @@ static int validateKey (Key * key, Key * parentKey) rc = rfc2822StringValidation (date); if (rc == -1) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "%s doesn't match rfc2822 specification", date); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Date '%s' doesn't match rfc2822 specification", date); rc = 0; } } @@ -446,7 +446,7 @@ static int validateKey (Key * key, Key * parentKey) rc = rfc822StringValidation (date); if (rc == -1) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "%s doesn't match format string %s", date, formatString); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Date '%s' doesn't match format string %s", date, formatString); rc = 0; } } diff --git a/src/plugins/enum/enum.c b/src/plugins/enum/enum.c index fcdd253eb36..88428202ce1 100644 --- a/src/plugins/enum/enum.c +++ b/src/plugins/enum/enum.c @@ -215,7 +215,7 @@ static int validateKey (Key * key, Key * parentKey) rc = validateWithArray (key); if (!rc) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Validation of key '%s' with string '%s' failed.", keyName (key), + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Validation of key '%s' with string '%s' failed", keyName (key), keyString (key)); } return rc; diff --git a/src/plugins/fcrypt/fcrypt.c b/src/plugins/fcrypt/fcrypt.c index b1088dc5942..0e9d6f67495 100644 --- a/src/plugins/fcrypt/fcrypt.c +++ b/src/plugins/fcrypt/fcrypt.c @@ -149,7 +149,7 @@ static int shredTemporaryFile (int fd, Key * errorKey) return 1; error: - ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Failed to overwrite the temporary data. Unencrypted data may leak. Errno: %s", + ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "Failed to overwrite the temporary data. Unencrypted data may leak. Reason: %s", strerror (errno)); return -1; } @@ -577,7 +577,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, fcryptState * s = (fcryptState *) elektraPluginGetData (handle); if (!s) { - ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "No plugin state is available."); + ELEKTRA_SET_INSTALLATION_ERROR (parentKey, "No plugin state is available"); return -1; } @@ -590,7 +590,7 @@ int ELEKTRA_PLUGIN_FUNCTION (get) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, } else { - ELEKTRA_SET_INTERNAL_ERROR (parentKey, "The path to the original file is lost."); + ELEKTRA_SET_INTERNAL_ERROR (parentKey, "The path to the original file is lost"); // clean-up is performed by kdb close return -1; } @@ -640,12 +640,12 @@ int ELEKTRA_PLUGIN_FUNCTION (set) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, int fd = open (configFile, O_RDWR); if (fd == -1) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open config file %s because %s", configFile, strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open config file %s. Reason: %s", configFile, strerror (errno)); return -1; } if (fsync (fd) == -1) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not fsync config file %s because %s", configFile, strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not fsync config file %s. Reason: %s", configFile, strerror (errno)); if (close (fd)) { ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to close a file descriptor: %s", strerror (errno)); diff --git a/src/plugins/gpgme/gpgme.c b/src/plugins/gpgme/gpgme.c index f12352251d4..2b19c5ecd8c 100644 --- a/src/plugins/gpgme/gpgme.c +++ b/src/plugins/gpgme/gpgme.c @@ -154,7 +154,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er if (err) { // TODO: Correct?? - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to receive the GPG key because: %s", gpgme_strerror (err)); + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to receive the GPG key. Reason: %s", gpgme_strerror (err)); elektraGpgmeKeylistFree (&list); return NULL; } @@ -184,7 +184,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er if (err) { // TODO: Correct?? - ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to receive the GPG key because: %s", + ELEKTRA_SET_INTERNAL_ERRORF (errorKey, "Failed to receive the GPG key. Reason: %s", gpgme_strerror (err)); elektraGpgmeKeylistFree (&list); return NULL; @@ -351,7 +351,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to create the gpgme context because: %s", gpgme_strerror (err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to create the gpgme context. Reason: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -366,7 +366,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) recipients = extractRecipientFromPluginConfig (pluginConfig, errorKey, ctx); if (!recipients) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "No valid recipients were specified."); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "No valid recipients were specified"); returnValue = -1; goto cleanup; } @@ -486,7 +486,7 @@ static int gpgDecrypt (ELEKTRA_UNUSED Plugin * handle, KeySet * data, Key * erro err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to the gpgme context because: %s", gpgme_strerror (err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to the gpgme context. Reason: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -602,7 +602,7 @@ int elektraGpgmeCheckconf (Key * errorKey, KeySet * conf) err = gpgme_new (&ctx); if (err) { - ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to create the gpgme context because: %s", gpgme_strerror (err)); + ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Failed to create the gpgme context. Reason: %s", gpgme_strerror (err)); return -1; // at this point nothing has been initialized } @@ -615,7 +615,7 @@ int elektraGpgmeCheckconf (Key * errorKey, KeySet * conf) } else { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "No valid recipients were specified."); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "No valid recipients were specified"); return -1; // failure } return 1; // success diff --git a/src/plugins/hexnumber/hexnumber.c b/src/plugins/hexnumber/hexnumber.c index 0a7e0f61abc..a9828c51de8 100644 --- a/src/plugins/hexnumber/hexnumber.c +++ b/src/plugins/hexnumber/hexnumber.c @@ -279,7 +279,7 @@ int parseConfig (KeySet * config, HexnumberData * data, Key * errorKey) if (!types) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Could not parse config! Types not set correctly."); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERROR (errorKey, "Could not parse config. Types not set correctly"); return ELEKTRA_PLUGIN_STATUS_ERROR; } diff --git a/src/plugins/hosts/hosts-get.c b/src/plugins/hosts/hosts-get.c index 605218d3591..ae8d71c8b7d 100644 --- a/src/plugins/hosts/hosts-get.c +++ b/src/plugins/hosts/hosts-get.c @@ -307,7 +307,7 @@ int elektraHostsGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * pa } else { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "General parse error: %s", strerror (errno)); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "General parse error. Reason: %s", strerror (errno)); ksDel (append); ret = -1; } diff --git a/src/plugins/ipaddr/ipaddr.c b/src/plugins/ipaddr/ipaddr.c index 2adbccec6b8..39bea8501c1 100644 --- a/src/plugins/ipaddr/ipaddr.c +++ b/src/plugins/ipaddr/ipaddr.c @@ -102,7 +102,7 @@ static int validateKey (Key * key, Key * parentKey) if (!rc) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Validation of key %s with value %s failed.", keyName (key), + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Validation of key %s with value %s failed", keyName (key), keyString (key)); } else if (rc == -1) diff --git a/src/plugins/jni/jni.c b/src/plugins/jni/jni.c index 6f4a5fef114..f97f8020f7f 100644 --- a/src/plugins/jni/jni.c +++ b/src/plugins/jni/jni.c @@ -96,7 +96,7 @@ static int call1Arg (Data * data, Key * errorKey, const char * method) result = (*data->env)->CallIntMethod (data->env, data->plugin, mid, jerrorKey); if ((*data->env)->ExceptionCheck (data->env)) { - ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERRORF (errorKey, "%s failed with exception", method); + ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERRORF (errorKey, "Method '%s' failed with exception", method); result = -1; } checkException (data, method, errorKey); @@ -137,7 +137,7 @@ static int call2Arg (Data * data, KeySet * ks, Key * errorKey, const char * meth result = (*data->env)->CallIntMethod (data->env, data->plugin, mid, jks, jkey); if ((*data->env)->ExceptionCheck (data->env)) { - ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERRORF (errorKey, "%s failed with exception", method); + ELEKTRA_SET_PLUGIN_MISBEHAVIOR_ERRORF (errorKey, "Method '%s' failed with exception", method); result = -1; } checkException (data, method, errorKey); diff --git a/src/plugins/macaddr/macaddr.c b/src/plugins/macaddr/macaddr.c index 466c6587f43..7481d5a2531 100644 --- a/src/plugins/macaddr/macaddr.c +++ b/src/plugins/macaddr/macaddr.c @@ -154,7 +154,7 @@ int elektraMacaddrGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * int rc = validateMac (cur); if (rc == VALIDATION_ERROR) { - ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "%s is not in a supported format.", keyString (cur)); + ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "String '%s' is not in a supported format", keyString (cur)); return ELEKTRA_PLUGIN_STATUS_ERROR; } diff --git a/src/plugins/mathcheck/mathcheck.c b/src/plugins/mathcheck/mathcheck.c index cc78132ad66..4ea2e3c288d 100644 --- a/src/plugins/mathcheck/mathcheck.c +++ b/src/plugins/mathcheck/mathcheck.c @@ -397,7 +397,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (fabs (elektraEFtoF (keyString (cur)) - result.value) > EPSILON) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s != %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Mathcheck failed: %s != %s", val1, val2); return -1; } } @@ -405,7 +405,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (fabs (elektraEFtoF (keyString (cur)) - result.value) < EPSILON) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s == %s but requirement was !=", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Mathcheck failed: %s == %s but requirement was !=", val1, val2); return -1; } } @@ -413,7 +413,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) >= result.value) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s not < %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Mathcheck failed: %s not < %s", val1, val2); return -1; } } @@ -421,7 +421,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) <= result.value) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s not > %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Mathcheck failed: %s not > %s", val1, val2); return -1; } } @@ -429,7 +429,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) > result.value) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s not <= %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Mathcheck failed: %s not <= %s", val1, val2); return -1; } } @@ -437,7 +437,7 @@ int elektraMathcheckSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key { if (elektraEFtoF (keyString (cur)) < result.value) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "%s not >= %s", val1, val2); + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Mathcheck failed: %s not >= %s", val1, val2); return -1; } } diff --git a/src/plugins/network/network.c b/src/plugins/network/network.c index 11e470dfa46..52bfdf1fa70 100644 --- a/src/plugins/network/network.c +++ b/src/plugins/network/network.c @@ -75,7 +75,7 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) service = getservbyname (keyString (toCheck), NULL); // NULL means we accept both tcp and udp if (service == NULL) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Could not find service with name %s on key %s. Errno: %s", + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Could not find service with name %s on key %s. Reason: %s", keyString (toCheck), keyName (toCheck), strerror (errno)); return -1; } @@ -93,7 +93,7 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) if (sockfd < 0) { - ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open a socket: %s", strerror (errno)); + ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open a socket. Reason: %s", strerror (errno)); } server = gethostbyname (hostname); @@ -106,7 +106,7 @@ int elektraPortInfo (Key * toCheck, Key * parentKey) } else { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "There was an error trying to connect to host %s: %s", hostname, + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "There was an error trying to connect to host '%s'. Reason: %s", hostname, strerror (errno)); return -1; } diff --git a/src/plugins/path/path.c b/src/plugins/path/path.c index 0b0b2698d21..2331f54d8f9 100644 --- a/src/plugins/path/path.c +++ b/src/plugins/path/path.c @@ -316,7 +316,7 @@ static int handleNoUserCase (Key * parentKey, const char * validPath, const char int result = access (validPath, modeMask); if (result != 0) { - ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "User %s does not have required permission (%s) on %s", p->pw_name, + ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "User '%s' does not have required permission (%s) on %s", p->pw_name, modes, validPath); return -1; }