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

Commit

Permalink
error: error message improvements, compilation fix, minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ZronekM committed Jun 22, 2019
1 parent c6722c0 commit cdf52e2
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 40 deletions.
7 changes: 5 additions & 2 deletions src/libs/elektra/backend.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,11 @@ Backend * backendOpen (KeySet * elektraConfig, KeySet * modules, KeySet * global
{
// no one cares about that config
if (!failure)
// TODO: Correct?
ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Unrecognised Config Tree: %s", keyBaseName (cur));
ELEKTRA_ADD_INSTALLATION_WARNINGF (
errorKey,
"Found garbage within the backend configuration. found: %s but expected config, "
"setplugins, getplugins, errorplugins or mountpoint",
keyBaseName (cur));
ksDel (cut);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libs/elektra/kdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ static void elektraSetCommit (Split * split, Key * parentKey)
if (ret == -1)
{
ELEKTRA_ADD_ASSERTION_WARNINGF (parentKey, "Error during commit. This means backend is broken: %s",
keyName (backend->mountpoint));
keyName (backend->mountpoint));
}
}
}
Expand Down Expand Up @@ -1336,7 +1336,7 @@ static void elektraSetRollback (Split * split, Key * parentKey)
if (ret == -1)
{
ELEKTRA_ADD_ASSERTION_WARNINGF (parentKey, "Error during rollback. This means backend is broken: %s",
keyName (backend->mountpoint));
keyName (backend->mountpoint));
}
}
}
Expand Down Expand Up @@ -1576,7 +1576,7 @@ int kdbSet (KDB * handle, KeySet * ks, Key * parentKey)
if (!found)
{
ELEKTRA_ADD_ASSERTION_WARNINGF (parentKey, "Error key %s not found in keyset even though it was found before",
keyName (errorKey));
keyName (errorKey));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/elektra/plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ int elektraProcessPlugins (Plugin ** plugins, KeySet * modules, KeySet * referen
}
else
{
// TODO: Correct?
ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Unknown additional entries in plugin: %s", keyString (cur));
ELEKTRA_ADD_INSTALLATION_WARNINGF (errorKey, "Unknown additional entries in plugin configuration: %s",
keyString (cur));
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/libs/highlevel/elektra_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ ElektraError * elektraErrorFromKey (Key * key)
ElektraError * elektraErrorKeyNotFound (const char * keyname)
{
char * description = elektraFormat ("The key '%s' could not be found.", keyname);
ElektraError * error = elektraErrorCreate (ELEKTRA_ERROR_LOGICAL, description, "highlevel", "unknown", 0);
ElektraError * error = elektraErrorCreate (ELEKTRA_ERROR_ASSERTION, description, "highlevel", "unknown", 0);
elektraFree (description);
return error;
}
Expand All @@ -176,7 +176,7 @@ ElektraError * elektraErrorWrongType (const char * keyname, KDBType expectedType
ElektraError * elektraErrorNullError (const char * function)
{
char * description = elektraFormat ("The value passed to the ElektraError ** argument of %s was NULL.", function);
ElektraError * error = elektraErrorCreate (ELEKTRA_ERROR_LOGICAL, description, "highlevel", "unknown", 0);
ElektraError * error = elektraErrorCreate (ELEKTRA_ERROR_ASSERTION, description, "highlevel", "unknown", 0);
elektraFree (description);
return error;
}
Expand Down
1 change: 1 addition & 0 deletions src/libs/opts/opts.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <kdbease.h>
#include <kdbhelper.h>
#include <kdbmeta.h>
#include <stdio.h>

#include <kdberrors.h>

Expand Down
3 changes: 1 addition & 2 deletions src/plugins/augeas/augeas.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ int elektraAugeasGenConf (KeySet * ks, Key * errorKey ELEKTRA_UNUSED)
}
else
{
// TODO: Correct?
ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Could not glob %s", f);
ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "Could not glob %s because of augeas", f);
retval = -1;
}
return retval;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/crypto/gcrypt_operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK
{
// TODO: Correct?
ELEKTRA_SET_ASSERTION_ERRORF (errorKey, "Failed to create a cryptographic key for encryption because: %s",
gcry_strerror (gcry_err));
gcry_strerror (gcry_err));
return -1;
}

Expand Down Expand Up @@ -116,7 +116,7 @@ static int getKeyIvForDecryption (KeySet * config, Key * errorKey, Key * masterK
saltBufferLen, iterations, KEY_BUFFER_SIZE, keyBuffer)))
{
ELEKTRA_SET_ASSERTION_ERRORF (errorKey, "Failed to restore the cryptographic key for decryption because: %s",
gcry_strerror (gcry_err));
gcry_strerror (gcry_err));
return -1;
}

Expand Down
4 changes: 2 additions & 2 deletions src/plugins/crypto/gpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK
case -1:
// fork() failed
// TODO: Correct?
ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "fork failed");
ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "fork failed with errno: %s", strerror (errno));
closePipe (pipe_stdin);
closePipe (pipe_stdout);
closePipe (pipe_stderr);
Expand Down Expand Up @@ -751,7 +751,7 @@ int ELEKTRA_PLUGIN_FUNCTION (gpgCall) (KeySet * conf, Key * errorKey, Key * msgK
case 1:
// bad signature
// TODO: Correct?
ELEKTRA_SET_INSTALLATION_ERROR (errorKey, "GPG reported a bad signature");
ELEKTRA_SET_INSTALLATION_ERRORF (errorKey, "GPG reported a bad signature. errno: %s", strerror (errno));
break;

case GPG_CALL_DUP_STDIN:
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/crypto/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ int ELEKTRA_PLUGIN_FUNCTION (getSaltFromMetakey) (Key * errorKey, Key * k, kdb_o
int result = ELEKTRA_PLUGIN_FUNCTION (base64Decode) (errorKey, keyString (meta), salt, &saltLenInternal);
if (result == -1)
{
ELEKTRA_SET_SEMANTIC_VALIDATION_ERROR (errorKey, "Salt was not stored Base64 encoded.");
ELEKTRA_SET_VALIDATION_SEMANTIC_ERROR (errorKey, "Salt was not stored Base64 encoded.");
return -1;
}
else if (result == -2)
Expand Down Expand Up @@ -174,7 +174,7 @@ int ELEKTRA_PLUGIN_FUNCTION (getSaltFromPayload) (Key * errorKey, Key * k, kdb_o
{
// TODO: Correct?
ELEKTRA_SET_ASSERTION_ERRORF (errorKey, "restored salt has invalid length of %u (payload length is: %zu)", restoredSaltLen,
payloadLen);
payloadLen);
if (salt) *salt = NULL;
return -1;
}
Expand Down
7 changes: 4 additions & 3 deletions src/plugins/crypto/openssl_operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ static int getKeyIvForEncryption (KeySet * config, Key * errorKey, Key * masterK
{
// TODO: Correct?
ELEKTRA_SET_ASSERTION_ERRORF (errorKey,
"Failed to create a cryptographic key for encryption. Libcrypto returned error code: %lu",
ERR_get_error ());
"Failed to create a cryptographic key for encryption. Libcrypto returned error code: %lu",
ERR_get_error ());
pthread_mutex_unlock (&mutex_ssl);
return -1;
}
Expand Down Expand Up @@ -529,7 +529,8 @@ char * elektraCryptoOpenSSLCreateRandomString (Key * errorKey, const kdb_unsigne
if (!RAND_bytes (buffer, length))
{
// TODO: Correct?
ELEKTRA_SET_ASSERTION_ERRORF (errorKey, "Failed to generate random string. libcrypto error code was: %lu", ERR_get_error ());
ELEKTRA_SET_ASSERTION_ERRORF (errorKey, "Failed to generate random string. libcrypto error code was: %lu",
ERR_get_error ());
pthread_mutex_unlock (&mutex_ssl);
return NULL;
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/gpgme/gpgme.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static gpgme_key_t * extractRecipientFromPluginConfig (KeySet * config, Key * er
{
// TODO: Correct?
ELEKTRA_SET_ASSERTION_ERRORF (errorKey, "Failed to receive the GPG key because: %s",
gpgme_strerror (err));
gpgme_strerror (err));
elektraGpgmeKeylistFree (&list);
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/network/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ 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",
keyString (toCheck), keyName (toCheck));
ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (parentKey, "Could not find service with name %s on key %s. Errno: %s",
keyString (toCheck), keyName (toCheck), strerror (errno));
return -1;
}
portNumberNetworkByteOrder = service->s_port;
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/path/path.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ static int validatePermission (Key * key, Key * parentKey)
if (euidResult != 0 || egidResult != 0)
{
ELEKTRA_SET_ASSERTION_ERROR (parentKey,
"There was a problem in the user switching process."
"Please report the issue at https://issues.libelektra.org");
"There was a problem in the user switching process."
"Please report the issue at https://issues.libelektra.org");
return -1;
}

Expand Down Expand Up @@ -239,13 +239,13 @@ static int getAllGroups (Key * parentKey, uid_t currentUID, const struct passwd
if (getgrouplist (p->pw_name, (int) p->pw_gid, (*groups), &ngroups) < 0)
{
ELEKTRA_SET_ASSERTION_ERROR (parentKey,
"There was a problem in the getting all groups for the user."
"Please report the issue at https://issues.libelektra.org");
"There was a problem in the getting all groups for the user."
"Please report the issue at https://issues.libelektra.org");
if (seteuid (currentUID) < 0)
{
ELEKTRA_SET_ASSERTION_ERROR (parentKey,
"There was a problem in the user switching process."
"Please report the issue at https://issues.libelektra.org");
"There was a problem in the user switching process."
"Please report the issue at https://issues.libelektra.org");
}
return -1;
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/quickdump/quickdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key
if (sourceKey == NULL)
{
ELEKTRA_SET_ASSERTION_ERRORF (parentKey, "Could not copy meta data from key '%s': Key not found",
nameBuffer.string);
nameBuffer.string);
keyDel (k);
elektraFree (nameBuffer.string);
elektraFree (metaNameBuffer.string);
Expand All @@ -399,8 +399,8 @@ int elektraQuickdumpGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key
if (keyCopyMeta (k, sourceKey, metaNameBuffer.string) != 1)
{
ELEKTRA_SET_ASSERTION_ERRORF (parentKey,
"Could not copy meta data from key '%s': Error during copy",
&nameBuffer.string[nameBuffer.offset]);
"Could not copy meta data from key '%s': Error during copy",
&nameBuffer.string[nameBuffer.offset]);
keyDel (k);
elektraFree (nameBuffer.string);
elektraFree (metaNameBuffer.string);
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/quickdump/readv1.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static int readVersion1 (FILE * file, KeySet * returned, Key * parentKey)
if (sourceKey == NULL)
{
ELEKTRA_SET_ASSERTION_ERRORF (parentKey, "Could not copy meta data from key '%s': Key not found",
keyName);
keyName);
keyDel (k);
elektraFree (keyName);
elektraFree (metaName);
Expand All @@ -156,8 +156,8 @@ static int readVersion1 (FILE * file, KeySet * returned, Key * parentKey)

if (keyCopyMeta (k, sourceKey, metaName) != 1)
{
ELEKTRA_SET_ASSERTION_ERRORF (
parentKey, "Could not copy meta data from key '%s': Error during copy", keyName);
ELEKTRA_SET_ASSERTION_ERRORF (parentKey,
"Could not copy meta data from key '%s': Error during copy", keyName);
keyDel (k);
elektraFree (keyName);
elektraFree (metaName);
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/resolver/resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ static void elektraUpdateFileTime (resolverHandle * pk, int fd, Key * parentKey)
{
// TODO: Correct?
ELEKTRA_ADD_ASSERTION_WARNINGF (parentKey, "Could not update time stamp of \"%s\", because %s",
fd == pk->fd ? pk->filename : pk->tempfile, strerror (errno));
fd == pk->fd ? pk->filename : pk->tempfile, strerror (errno));
}
#elif defined(HAVE_FUTIMES)
const struct timeval times[2] = { { pk->mtime.tv_sec, pk->mtime.tv_nsec / 1000 }, // atime
Expand All @@ -982,7 +982,7 @@ static void elektraUpdateFileTime (resolverHandle * pk, int fd, Key * parentKey)
{
// TODO: Correct?
ELEKTRA_ADD_ASSERTION_WARNINGF (parentKey, "Could not update time stamp of \"%s\", because %s",
fd == pk->fd ? pk->filename : pk->tempfile, strerror (errno));
fd == pk->fd ? pk->filename : pk->tempfile, strerror (errno));
}
#else
#warning futimens/futimes not defined
Expand Down Expand Up @@ -1061,7 +1061,7 @@ static int elektraSetCommit (resolverHandle * pk, Key * parentKey)
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));
pk->tempfile, buf.st_mode, pk->filemode, strerror (errno));
}
}

Expand All @@ -1070,7 +1070,7 @@ 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));
pk->tempfile, buf.st_uid, buf.st_gid, pk->uid, pk->gid, strerror (errno));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/yamlcpp/yamlcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ int elektraYamlcppSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned, Key *
catch (YAML::EmitterException const & exception)
{
ELEKTRA_SET_ASSERTION_ERRORF (parent.getKey (), "Something went wrong while emitting YAML data to file “%s”: %s.",
parent.getString ().c_str (), exception.what ());
parent.getString ().c_str (), exception.what ());
}

parent.release ();
Expand Down

0 comments on commit cdf52e2

Please sign in to comment.