diff --git a/doc/news/_preparation_next_release.md b/doc/news/_preparation_next_release.md index fd2e7d964f9..093390c1f1c 100644 --- a/doc/news/_preparation_next_release.md +++ b/doc/news/_preparation_next_release.md @@ -345,6 +345,7 @@ you up to date with the multi-language support provided by Elektra. - Improved various error messages and synchronized documentations. _(Michael Zronek)_ - Improved `range` plugin error message. _(Michael Zronek)_ - Improved error codes documentation to clarify the hierarchy for developers. _(Michael Zronek)_ +- Out of memory error messages are now uniform. _(Michael Zronek)_ - Release notes now use git's union merge driver. _(Dominic Jäger)_ - Please remove me. I'm only here for the build server. _(Dominic Jäger)_ - I'm only here for the build server. This PR contains only fix ups. _(Dominic Jäger)_ diff --git a/src/include/kdberrors.h b/src/include/kdberrors.h index 9c6cb34e0dd..386629848f1 100644 --- a/src/include/kdberrors.h +++ b/src/include/kdberrors.h @@ -51,33 +51,20 @@ using KeySet = ckdb::KeySet; __VA_ARGS__); \ } while (0) -#define ELEKTRA_SET_OUT_OF_MEMORY_ERROR(key, reason) \ +#define ELEKTRA_SET_OUT_OF_MEMORY_ERROR(key) \ do \ { \ - ELEKTRA_LOG ("Add Error %s: %s", ELEKTRA_ERROR_OUT_OF_MEMORY, reason); \ + ELEKTRA_LOG ("Add Error %s", ELEKTRA_ERROR_OUT_OF_MEMORY); \ elektraSetErrorOUT_OF_MEMORY (key, __FILE__, ELEKTRA_STRINGIFY (__LINE__), ELEKTRA_STRINGIFY (ELEKTRA_MODULE_NAME), \ - reason); \ + "Memory allocation failed"); \ } while (0) -#define ELEKTRA_SET_OUT_OF_MEMORY_ERRORF(key, reason, ...) \ - do \ - { \ - ELEKTRA_LOG ("Add Error %s: " reason, ELEKTRA_ERROR_OUT_OF_MEMORY, __VA_ARGS__); \ - elektraSetErrorOUT_OF_MEMORY (key, __FILE__, ELEKTRA_STRINGIFY (__LINE__), ELEKTRA_STRINGIFY (ELEKTRA_MODULE_NAME), \ - reason, __VA_ARGS__); \ - } while (0) -#define ELEKTRA_ADD_OUT_OF_MEMORY_WARNING(key, reason) \ - do \ - { \ - ELEKTRA_LOG ("Add Warning %s: %s", ELEKTRA_WARNING_OUT_OF_MEMORY, reason); \ - elektraAddWarningOUT_OF_MEMORY (key, __FILE__, ELEKTRA_STRINGIFY (__LINE__), ELEKTRA_STRINGIFY (ELEKTRA_MODULE_NAME), \ - reason); \ - } while (0) -#define ELEKTRA_ADD_OUT_OF_MEMORY_WARNINGF(key, reason, ...) \ + +#define ELEKTRA_ADD_OUT_OF_MEMORY_WARNING(key) \ do \ { \ - ELEKTRA_LOG ("Add Warning %s: " reason, ELEKTRA_WARNING_OUT_OF_MEMORY, __VA_ARGS__); \ + ELEKTRA_LOG ("Add Warning %s: %s", ELEKTRA_WARNING_OUT_OF_MEMORY, "Memory allocation failed"); \ elektraAddWarningOUT_OF_MEMORY (key, __FILE__, ELEKTRA_STRINGIFY (__LINE__), ELEKTRA_STRINGIFY (ELEKTRA_MODULE_NAME), \ - reason, __VA_ARGS__); \ + "Memory allocation failed"); \ } while (0) #define ELEKTRA_SET_INSTALLATION_ERROR(key, reason) \ diff --git a/src/include/kdbmacros.h b/src/include/kdbmacros.h index 9beef2ce2a2..dba6a799d49 100644 --- a/src/include/kdbmacros.h +++ b/src/include/kdbmacros.h @@ -61,8 +61,6 @@ strerror (errno)); \ } while (0) -#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/libs/elektra/errors.c b/src/libs/elektra/errors.c index 1bbdcc4b304..45ea66b9ddb 100644 --- a/src/libs/elektra/errors.c +++ b/src/libs/elektra/errors.c @@ -190,7 +190,7 @@ void elektraTriggerWarnings (const char * nr, Key * parentKey, const char * mess } if (strcmp (nr, ELEKTRA_WARNING_OUT_OF_MEMORY) == 0) { - ELEKTRA_ADD_OUT_OF_MEMORY_WARNING (parentKey, message); + ELEKTRA_ADD_OUT_OF_MEMORY_WARNING (parentKey); return; } if (strcmp (nr, ELEKTRA_WARNING_INSTALLATION) == 0) @@ -240,7 +240,7 @@ void elektraTriggerError (const char * nr, Key * parentKey, const char * message } if (strcmp (nr, ELEKTRA_ERROR_OUT_OF_MEMORY) == 0) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, message); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return; } if (strcmp (nr, ELEKTRA_ERROR_INSTALLATION) == 0) diff --git a/src/libs/merge/kdbmerge.c b/src/libs/merge/kdbmerge.c index 6cdaf4b6073..0f79bb82321 100644 --- a/src/libs/merge/kdbmerge.c +++ b/src/libs/merge/kdbmerge.c @@ -712,7 +712,7 @@ static char * getValuesAsArray (KeySet * ks, const Key * arrayStart, Key * infor } if (elektraRealloc ((void **) &buffer, bufferSize) < 0) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (informationKey, "Memory allocation failed."); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (informationKey); elektraFree (buffer); keyDel (iterator); return NULL; @@ -776,14 +776,14 @@ static KeySet * ksFromArray (const char * array, int length, Key * informationKe KeySet * result = ksNew (0, KS_END); if (result == NULL) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (informationKey, "Memory allocation failed."); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (informationKey); return NULL; } Key * iterator = keyNew ("/#0", KEY_END); if (iterator == NULL) { ksDel (result); - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (informationKey, "Memory allocation failed."); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (informationKey); return NULL; } char * buffer = elektraCalloc (length + 1); // + 1 for terminating null character diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 504253c04ac..60d04139a05 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -415,7 +415,7 @@ static int saveTree (augeas * augeasHandle, KeySet * ks, const char * lensPath, memoryerror: elektraFree (keyArray); - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Unable to allocate memory while saving the augeas tree"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return -1; } @@ -432,7 +432,7 @@ int elektraAugeasOpen (Plugin * handle, Key * parentKey) if (ret >= 0) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Unable to allocate memory for a detailed augeas error message"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return -1; } @@ -521,7 +521,7 @@ int elektraAugeasGet (Plugin * handle, KeySet * returned, Key * parentKey) if (!conversionData) { fclose (fh); - ELEKTRA_SET_OUT_OF_MEMORY_ERRORF (parentKey, "Out of memory. Errno: %s", strerror (errno)); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); } conversionData->currentOrder = 0; diff --git a/src/plugins/base64/base64.c b/src/plugins/base64/base64.c index 2f0c7f324ab..41f2ec7caaf 100644 --- a/src/plugins/base64/base64.c +++ b/src/plugins/base64/base64.c @@ -36,7 +36,7 @@ static int unescape (Key * key, Key * parent) char * unescaped = elektraStrDup (&strVal[1]); if (!unescaped) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent); return -1; } keySetString (key, unescaped); @@ -112,7 +112,7 @@ static int decode (Key * key, Key * parent, bool metaMode) else if (result == -2) { // Memory error - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent); return -1; } @@ -138,7 +138,7 @@ static int encode (Key * key, Key * parent, bool metaMode) char * base64 = base64Encode (keyValue (key), (size_t) keyGetValueSize (key)); if (!base64) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent); return -1; } @@ -152,7 +152,7 @@ static int encode (Key * key, Key * parent, bool metaMode) char * newVal = elektraMalloc (newValLen); if (!newVal) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent); elektraFree (base64); return -1; } @@ -192,7 +192,7 @@ static int escape (Key * key, Key * parent) char * escapedVal = elektraMalloc (strValLen + 2); if (!escapedVal) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent); return -1; } diff --git a/src/plugins/conditionals/conditionals.c b/src/plugins/conditionals/conditionals.c index 7989cd595a1..72a3f7c9853 100644 --- a/src/plugins/conditionals/conditionals.c +++ b/src/plugins/conditionals/conditionals.c @@ -207,7 +207,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp } if (elektraRealloc ((void **) &compareTo, (size_t) (endPos - rightSide)) < 0) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); result = ERROR; goto Cleanup; } @@ -226,7 +226,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp if (elektraRealloc ((void **) &lookupName, (size_t) len) < 0) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); result = ERROR; goto Cleanup; } @@ -251,7 +251,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp } if (elektraRealloc ((void **) &compareTo, (size_t) keyGetValueSize (key)) < 0) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); result = ERROR; goto Cleanup; } @@ -267,7 +267,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp if (elektraRealloc ((void **) &lookupName, (size_t) len) < 0) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); result = ERROR; goto Cleanup; } @@ -562,8 +562,7 @@ static CondResult parseCondition (Key * key, const char * condition, const Key * if ((regcomp (®ex, regexString, REG_EXTENDED | REG_NEWLINE))) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); // the regex compiles so the only // possible error would be out of // memory ksDel (ks); @@ -617,8 +616,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList CondResult ret; if ((ret = regcomp (®ex1, regexString1, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); // the regex compiles so the only // possible error would be out of // memory ksDel (ks); @@ -626,8 +624,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if ((ret = regcomp (®ex2, regexString2, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); // the regex compiles so the only // possible error would be out of // memory regfree (®ex1); @@ -636,8 +633,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList } if ((ret = regcomp (®ex3, regexString3, REGEX_FLAGS_CONDITION))) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, - "Couldn't compile regex: most likely out of memory"); // the regex compiles so the only + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); // the regex compiles so the only // possible error would be out of // memory regfree (®ex1); diff --git a/src/plugins/crypto/botan_operations.cpp b/src/plugins/crypto/botan_operations.cpp index e2832856c4c..19c7d4e25e8 100644 --- a/src/plugins/crypto/botan_operations.cpp +++ b/src/plugins/crypto/botan_operations.cpp @@ -66,7 +66,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } if (!saltHexString) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); diff --git a/src/plugins/crypto/gcrypt_operations.c b/src/plugins/crypto/gcrypt_operations.c index 3a0d3233cb4..1f85214b4a2 100644 --- a/src/plugins/crypto/gcrypt_operations.c +++ b/src/plugins/crypto/gcrypt_operations.c @@ -58,7 +58,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } if (!saltHexString) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); @@ -205,7 +205,7 @@ int elektraCryptoGcryHandleCreate (elektraCryptoHandle ** handle, KeySet * confi memset (ivBuffer, 0, sizeof (ivBuffer)); keyDel (key); keyDel (iv); - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } @@ -293,7 +293,7 @@ int elektraCryptoGcryEncrypt (elektraCryptoHandle * handle, Key * k, Key * error kdb_octet_t * output = elektraMalloc (outputLen); if (!output) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); elektraFree (salt); return -1; } @@ -373,7 +373,7 @@ int elektraCryptoGcryDecrypt (elektraCryptoHandle * handle, Key * k, Key * error kdb_octet_t * output = elektraMalloc (payloadLen); if (!output) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } @@ -446,7 +446,7 @@ char * elektraCryptoGcryCreateRandomString (Key * errorKey, const kdb_unsigned_s } if (!encoded) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); } return encoded; } diff --git a/src/plugins/crypto/gpg.c b/src/plugins/crypto/gpg.c index 6afa9ebfccc..81443499373 100644 --- a/src/plugins/crypto/gpg.c +++ b/src/plugins/crypto/gpg.c @@ -116,7 +116,7 @@ static char * genGpgCandidate (Key * errorKey, char * dir, const char * file) char * result = elektraMalloc (resultLen); if (!result) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return NULL; } snprintf (result, resultLen, "%s/%s", dir, file); @@ -146,7 +146,7 @@ static int searchPathForBin (Key * errorKey, const char * bin, char ** result) char * path = elektraMalloc (envPathLen); if (!path) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } memcpy (path, envPath, envPathLen); @@ -196,7 +196,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgGetBinary) (char ** gpgBin, KeySet * conf, Key * *gpgBin = elektraMalloc (configPathLen + 1); if (!(*gpgBin)) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } strncpy (*gpgBin, configPath, configPathLen); @@ -237,7 +237,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgGetBinary) (char ** gpgBin, KeySet * conf, Key * *gpgBin = elektraStrDup (ELEKTRA_CRYPTO_DEFAULT_GPG2_BIN); if (!(*gpgBin)) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } return 1; @@ -249,7 +249,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgGetBinary) (char ** gpgBin, KeySet * conf, Key * *gpgBin = elektraStrDup (ELEKTRA_CRYPTO_DEFAULT_GPG1_BIN); if (!(*gpgBin)) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } return 1; @@ -645,7 +645,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK // estimated maximum output size = 2 * input (including headers, etc.) if (msgKey && !(buffer = elektraMalloc (bufferSize))) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); closePipe (pipe_stdin); closePipe (pipe_stdout); closePipe (pipe_stderr); diff --git a/src/plugins/crypto/helper.c b/src/plugins/crypto/helper.c index c0da504189f..b3c38816587 100644 --- a/src/plugins/crypto/helper.c +++ b/src/plugins/crypto/helper.c @@ -125,7 +125,7 @@ int ELEKTRA_PLUGIN_FUNCTION (getSaltFromMetakey) (Key * errorKey, Key * k, kdb_o } else if (result == -2) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } else if (result < -2) diff --git a/src/plugins/crypto/openssl_operations.c b/src/plugins/crypto/openssl_operations.c index 3b3c9c32d1c..2a44f1d757d 100644 --- a/src/plugins/crypto/openssl_operations.c +++ b/src/plugins/crypto/openssl_operations.c @@ -73,7 +73,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK } if (!saltHexString) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } keySetMeta (k, ELEKTRA_CRYPTO_META_SALT, saltHexString); @@ -223,7 +223,7 @@ int elektraCryptoOpenSSLHandleCreate (elektraCryptoHandle ** handle, KeySet * co { memset (keyBuffer, 0, sizeof (keyBuffer)); memset (ivBuffer, 0, sizeof (ivBuffer)); - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; } @@ -307,7 +307,7 @@ int elektraCryptoOpenSSLEncrypt (elektraCryptoHandle * handle, Key * k, Key * er encrypted = BIO_new (BIO_s_mem ()); if (!encrypted) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); pthread_mutex_unlock (&mutex_ssl); elektraFree (salt); return -1; @@ -433,7 +433,7 @@ int elektraCryptoOpenSSLDecrypt (elektraCryptoHandle * handle, Key * k, Key * er BIO * decrypted = BIO_new (BIO_s_mem ()); if (!decrypted) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); pthread_mutex_unlock (&mutex_ssl); return -1; } @@ -535,7 +535,7 @@ char * elektraCryptoOpenSSLCreateRandomString (Key * errorKey, const kdb_unsigne } if (!encoded) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); } return encoded; } diff --git a/src/plugins/fcrypt/fcrypt.c b/src/plugins/fcrypt/fcrypt.c index e6e4119ce37..c036f8e2e22 100644 --- a/src/plugins/fcrypt/fcrypt.c +++ b/src/plugins/fcrypt/fcrypt.c @@ -295,7 +295,7 @@ static int fcryptEncrypt (KeySet * pluginConfig, Key * parentKey) char * tmpFile = getTemporaryFileName (pluginConfig, keyString (parentKey), &tmpFileFd); if (!tmpFile) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return -1; } @@ -434,7 +434,7 @@ static int fcryptDecrypt (KeySet * pluginConfig, Key * parentKey, fcryptState * char * tmpFile = getTemporaryFileName (pluginConfig, keyString (parentKey), &tmpFileFd); if (!tmpFile) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return -1; } @@ -513,7 +513,7 @@ int ELEKTRA_PLUGIN_FUNCTION (open) (Plugin * handle, KeySet * ks ELEKTRA_UNUSED, fcryptState * s = elektraMalloc (sizeof (fcryptState)); if (!s) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return -1; } diff --git a/src/plugins/file/file.c b/src/plugins/file/file.c index 115e1302da3..6199887cf63 100644 --- a/src/plugins/file/file.c +++ b/src/plugins/file/file.c @@ -62,7 +62,7 @@ int elektraFileGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN if (!buffer) { - ELEKTRA_SET_OUT_OF_MEMORY_ERRORF (parentKey, "Failed to allocate buffer of %lld bytes for %s", fileSize, fileName); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return -1; } @@ -155,7 +155,7 @@ int elektraFileSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA_UN unsigned char * value = elektraMalloc (valueSize); if (!value) { - ELEKTRA_MALLOC_ERROR (parentKey, valueSize); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); fclose (fp); return -1; } diff --git a/src/plugins/gpgme/gpgme.c b/src/plugins/gpgme/gpgme.c index e2ce378bc58..24ec6fd5100 100644 --- a/src/plugins/gpgme/gpgme.c +++ b/src/plugins/gpgme/gpgme.c @@ -163,7 +163,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er { if (!elektraGpgmeKeylistAdd (&list, key)) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); elektraGpgmeKeylistFree (&list); return NULL; } @@ -193,7 +193,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er { if (!elektraGpgmeKeylistAdd (&list, key)) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); elektraGpgmeKeylistFree (&list); return NULL; } @@ -211,7 +211,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er gpgme_key_t * keyArray = elektraMalloc ((list.size + 1) * sizeof (gpgme_key_t)); if (!keyArray) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); elektraGpgmeKeylistFree (&list); return NULL; } @@ -250,7 +250,7 @@ static int transferGpgmeDataToElektraKey (gpgme_data_t src, Key * dst, Key * err buffer = (char *) elektraMalloc (ciphertextLen); if (!buffer) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); returnValue = -1; // failure goto cleanup; } @@ -438,7 +438,7 @@ static int gpgEncrypt (Plugin * handle, KeySet * data, Key * errorKey) } else { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); } gpgme_data_release (ciphertext); gpgme_data_release (input); diff --git a/src/plugins/hexnumber/hexnumber.c b/src/plugins/hexnumber/hexnumber.c index a9828c51de8..fad23ea90dc 100644 --- a/src/plugins/hexnumber/hexnumber.c +++ b/src/plugins/hexnumber/hexnumber.c @@ -91,7 +91,7 @@ static int convertHexToDec (Key * key, Key * parentKey) char * decValue = elektraMalloc (length); if (!decValue) { - ELEKTRA_MALLOC_ERROR (parentKey, length); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return ELEKTRA_PLUGIN_STATUS_ERROR; } @@ -160,7 +160,7 @@ static int convertDecToHex (Key * key, Key * parentKey) char * hexValue = elektraMalloc (length); if (!hexValue) { - ELEKTRA_MALLOC_ERROR (parentKey, length); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); return ELEKTRA_PLUGIN_STATUS_ERROR; } diff --git a/src/plugins/ini/ini.c b/src/plugins/ini/ini.c index 4494dc5f4de..bc14c933fcd 100644 --- a/src/plugins/ini/ini.c +++ b/src/plugins/ini/ini.c @@ -783,7 +783,7 @@ int elektraIniGet (Plugin * handle, KeySet * returned, Key * parentKey) ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Unable to open the ini file"); break; case -2: - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Memory allocation error while reading the ini file"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); break; default: ELEKTRA_SET_VALIDATION_SYNTACTIC_ERRORF (parentKey, "Could not parse ini file %s. First error at line %d", diff --git a/src/plugins/ipaddr/ipaddr.c b/src/plugins/ipaddr/ipaddr.c index 39bea8501c1..9ed7f92864f 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_OUT_OF_MEMORY_ERROR (parentKey, "Out of memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); rc = 0; } diff --git a/src/plugins/jni/jni.c b/src/plugins/jni/jni.c index 78ce3e29f05..8182e89cdb5 100644 --- a/src/plugins/jni/jni.c +++ b/src/plugins/jni/jni.c @@ -227,7 +227,7 @@ int elektraJniOpen (Plugin * handle, Key * errorKey) ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "Cannot create Java VM: JNI version error"); return -1; case JNI_ENOMEM: - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Cannot create Java VM: Not enough memory"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey); return -1; case JNI_EEXIST: ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Cannot create Java VM: VM already created"); diff --git a/src/plugins/keytometa/keytometa.c b/src/plugins/keytometa/keytometa.c index 15f422b660a..4bf1341e590 100644 --- a/src/plugins/keytometa/keytometa.c +++ b/src/plugins/keytometa/keytometa.c @@ -254,7 +254,7 @@ int elektraKeyToMetaGet (Plugin * handle, KeySet * returned, Key * parentKey ELE if (ret < 0) { elektraFree (keyArray); - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, "Memory allocation failed"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); errno = errnosave; return 0; } diff --git a/src/plugins/lua/lua.cpp b/src/plugins/lua/lua.cpp index ef90b3f9db4..be2625eac15 100644 --- a/src/plugins/lua/lua.cpp +++ b/src/plugins/lua/lua.cpp @@ -147,7 +147,7 @@ int elektraLuaOpen (ckdb::Plugin * handle, ckdb::Key * errorKey) /* init new lua state */ if ((data->L = lua_newstate (Lua_alloc, NULL)) == NULL) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (errorKey, "Unable to create new lua state"); + ELEKTRA_SET_RESOURCE_ERROR (errorKey, "Unable to create new lua state"); goto error; } diff --git a/src/plugins/multifile/multifile.c b/src/plugins/multifile/multifile.c index ce4d8081b83..696ff9b17b7 100644 --- a/src/plugins/multifile/multifile.c +++ b/src/plugins/multifile/multifile.c @@ -408,7 +408,7 @@ static Codes updateFilesGlob (Plugin * handle, MultiConfig * mc, KeySet * found, { if (ret == GLOB_NOSPACE) { - ELEKTRA_SET_OUT_OF_MEMORY_ERRORF (parentKey, "Glob(%s) ran out of memory", pattern); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); } else if (ret == GLOB_ABORTED) { diff --git a/src/plugins/resolver/filename.c b/src/plugins/resolver/filename.c index 4377c19616f..67ef527c6e7 100644 --- a/src/plugins/resolver/filename.c +++ b/src/plugins/resolver/filename.c @@ -484,7 +484,7 @@ static char * elektraGetCwd (Key * warningsKey) char * cwd = elektraMalloc (size); if (cwd == NULL) { - ELEKTRA_ADD_OUT_OF_MEMORY_WARNING (warningsKey, "Could not alloc for getcwd, defaulting to /"); + ELEKTRA_ADD_RESOURCE_WARNING (warningsKey, "Could not alloc for getcwd, defaulting to /"); return 0; } @@ -509,8 +509,8 @@ static char * elektraGetCwd (Key * warningsKey) elektraRealloc ((void **) &cwd, size); if (cwd == NULL) { - ELEKTRA_ADD_OUT_OF_MEMORY_WARNINGF (warningsKey, - "Could not realloc for `getcwd()` size %d, defaulting to /", size); + ELEKTRA_ADD_RESOURCE_WARNINGF (warningsKey, "Could not realloc for `getcwd()` size %d, defaulting to /", + size); return 0; } } diff --git a/src/plugins/xerces/xerces.cpp b/src/plugins/xerces/xerces.cpp index fa7771004dd..490621b4894 100644 --- a/src/plugins/xerces/xerces.cpp +++ b/src/plugins/xerces/xerces.cpp @@ -66,7 +66,7 @@ int elektraXercesGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (const OutOfMemoryException & e) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); } catch (const XMLException & e) { @@ -104,7 +104,7 @@ int elektraXercesSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key * p } catch (const OutOfMemoryException & e) { - ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey, asCStr (e.getMessage ())); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parentKey); } catch (const XMLException & e) { diff --git a/src/plugins/yambi/convert.cpp b/src/plugins/yambi/convert.cpp index fe615338603..6d121bd5727 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_OUT_OF_MEMORY_ERROR (parent.getKey (), "Parsing failed due to memory exhaustion"); + ELEKTRA_SET_OUT_OF_MEMORY_ERROR (parent.getKey ()); } else if (status == -1) {