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

Commit

Permalink
error: RESOURCE -> GENERAL_RESOURCE migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ZronekM committed Jun 22, 2019
1 parent 4a5c3b1 commit 75ceb83
Show file tree
Hide file tree
Showing 37 changed files with 147 additions and 147 deletions.
2 changes: 1 addition & 1 deletion doc/tutorials/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Basically the implementation of `elektraLineSet` can be described with the follo
// open the file
if (error)
{
ELEKTRA_SET_RESOURCE_ERROR( parentKey, keyString(parentKey));
ELEKTRA_SET_GENERAL_RESOURCE_ERROR( parentKey, keyString(parentKey));
}
for (/* each key */)
{
Expand Down
2 changes: 1 addition & 1 deletion src/error/specification
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ macro:OUT_OF_MEMORY

number:C01120
description:General Resource
macro:RESOURCE
macro:GENERAL_RESOURCE

number:C01300
description:Installation
Expand Down
10 changes: 5 additions & 5 deletions src/include/kdbmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,30 @@
do \
{ \
if (errno == EACCES) \
ELEKTRA_SET_RESOURCE_ERRORF ( \
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF ( \
parentKey, \
"Insufficient permissions to open configuration file for reading. Reason: %s. You might want " \
"to retry as root or change access using chmod.", \
strerror (errno)); \
else \
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Could not open configuration file for reading. Reason: %s", \
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Could not open configuration file for reading. Reason: %s", \
strerror (errno)); \
} while (0)

#define ELEKTRA_SET_ERROR_SET(parentKey) \
do \
{ \
if (errno == EACCES) \
ELEKTRA_SET_RESOURCE_ERRORF ( \
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF ( \
parentKey, \
"Insufficient permissions to open configuration file for writing. You might want to retry as " \
"root. Errno: %s", \
strerror (errno)); \
else \
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, ":Could not open file for writing %s", strerror (errno)); \
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, ":Could not open file for writing %s", strerror (errno)); \
} while (0)

#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_RESOURCE_ERRORF (key, "Unable to allocate %zu bytes.", size);
#define ELEKTRA_MALLOC_ERROR(key, size) ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (key, "Unable to allocate %zu bytes.", size);

/**
* @brief Sets error if info != returned
Expand Down
2 changes: 1 addition & 1 deletion src/libs/elektra/kdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ int kdbClose (KDB * handle, Key * errorKey)
}
else
{
ELEKTRA_ADD_RESOURCE_WARNING (errorKey, "Could not close modules: modules were not open");
ELEKTRA_ADD_GENERAL_RESOURCE_WARNING (errorKey, "Could not close modules: modules were not open");
}

if (handle->global) ksDel (handle->global);
Expand Down
2 changes: 1 addition & 1 deletion src/libs/loader/dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ int elektraModulesClose (KeySet * modules, Key * errorKey)
}
ret = -1;
// TODO: Correct?
ELEKTRA_ADD_RESOURCE_WARNINGF (errorKey, "Could not close a module, dlclose failed: %s", dlerror ());
ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (errorKey, "Could not close a module, dlclose failed: %s", dlerror ());

ksAppendKey (newModules, cur);
}
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/augeas/augeas.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static int saveTree (augeas * augeasHandle, KeySet * ks, const char * lensPath,

memoryerror:
elektraFree (keyArray);
ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Unable to allocate memory while saving the augeas tree");
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Unable to allocate memory while saving the augeas tree");
return -1;
}

Expand All @@ -432,7 +432,7 @@ int elektraAugeasOpen (Plugin * handle, Key * parentKey)

if (ret >= 0)
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Unable to allocate memory for a detailed augeas error message");
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Unable to allocate memory for a detailed augeas error message");
return -1;
}

Expand Down Expand Up @@ -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_GENERAL_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno));
}

/* convert the string into an augeas tree */
Expand Down Expand Up @@ -578,7 +578,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_GENERAL_RESOURCE_ERRORF (parentKey, "Error while reading file: %s", strerror (errno));
}

/* convert the string into an augeas tree */
Expand All @@ -605,7 +605,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_GENERAL_RESOURCE_ERRORF (parentKey, "Could not open file for writing: %s", strerror (errno));

errno = errnosave;
return 1;
Expand Down
14 changes: 7 additions & 7 deletions src/plugins/blockresolver/blockresolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
struct stat buf;
if (stat (data->realFile, &buf))
{
ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile);
ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile);
return -1;
}
if (buf.st_mtime == data->mtime) return 0;
Expand All @@ -264,7 +264,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
fin = fopen (data->realFile, "r");
if (!fin)
{
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile);
goto GET_CLEANUP;
}

Expand All @@ -289,7 +289,7 @@ int elektraBlockresolverGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
fout = fopen (data->tmpFile, "w");
if (!fout)
{
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->tmpFile);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->tmpFile);
retVal = -1;
goto GET_CLEANUP;
}
Expand All @@ -312,7 +312,7 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
struct stat buf;
if (stat (data->realFile, &buf))
{
ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile);
ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (parentKey, "Failed to stat file %s\n", data->realFile);
return -1;
}
if (buf.st_mtime > data->mtime)
Expand All @@ -337,13 +337,13 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
fout = fopen (mergeFile, "w");
if (!fout)
{
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->realFile);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for writing", data->realFile);
goto SET_CLEANUP;
}
fin = fopen (data->realFile, "r");
if (!fin)
{
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->realFile);
goto SET_CLEANUP;
}
block = (char *) getBlock (fin, 0, data->startPos);
Expand All @@ -367,7 +367,7 @@ int elektraBlockresolverSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned E
fin = fopen (data->tmpFile, "r");
if (!fin)
{
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->tmpFile);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Couldn't open %s for reading", data->tmpFile);
goto SET_CLEANUP;
}
char buffer[BUFSIZE_MAX];
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/cache/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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_GENERAL_RESOURCE_ERRORF (parentKey, "Could not rename file. Errno: %s", strerror (errno));
goto error;
}

Expand Down
16 changes: 8 additions & 8 deletions src/plugins/conditionals/conditionals.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp
}
if (elektraRealloc ((void **) &compareTo, endPos - rightSide) < 0)
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory");
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory");
result = ERROR;
goto Cleanup;
}
Expand All @@ -228,7 +228,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp

if (elektraRealloc ((void **) &lookupName, len) < 0)
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory");
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory");
result = ERROR;
goto Cleanup;
}
Expand All @@ -253,7 +253,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp
}
if (elektraRealloc ((void **) &compareTo, keyGetValueSize (key)) < 0)
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory");
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory");
result = ERROR;
goto Cleanup;
}
Expand All @@ -269,7 +269,7 @@ static CondResult evalCondition (const Key * curKey, const char * leftSide, Comp

if (elektraRealloc ((void **) &lookupName, len) < 0)
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Out of memory");
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Out of memory");
result = ERROR;
goto Cleanup;
}
Expand Down Expand Up @@ -564,7 +564,7 @@ static CondResult parseCondition (Key * key, const char * condition, const Key *

if ((regcomp (&regex, regexString, REG_EXTENDED | REG_NEWLINE)))
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey,
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey,
"Couldn't compile regex: most likely out of memory"); // the regex compiles so the only
// possible error would be out of
// memory
Expand Down Expand Up @@ -619,7 +619,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList
CondResult ret;
if ((ret = regcomp (&regex1, regexString1, REGEX_FLAGS_CONDITION)))
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey,
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey,
"Couldn't compile regex: most likely out of memory"); // the regex compiles so the only
// possible error would be out of
// memory
Expand All @@ -628,7 +628,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList
}
if ((ret = regcomp (&regex2, regexString2, REGEX_FLAGS_CONDITION)))
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey,
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey,
"Couldn't compile regex: most likely out of memory"); // the regex compiles so the only
// possible error would be out of
// memory
Expand All @@ -638,7 +638,7 @@ static CondResult parseConditionString (const Key * meta, const Key * suffixList
}
if ((ret = regcomp (&regex3, regexString3, REGEX_FLAGS_CONDITION)))
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey,
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey,
"Couldn't compile regex: most likely out of memory"); // the regex compiles so the only
// possible error would be out of
// memory
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/crypto/gpg.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static int isExecutable (const char * file, Key * errorKey)
{
if (errorKey)
{
ELEKTRA_SET_RESOURCE_ERRORF (errorKey, "gpg binary %s has no permission to execute", file);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (errorKey, "gpg binary %s has no permission to execute", file);
}
return -2;
}
Expand Down Expand Up @@ -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_GENERAL_RESOURCE_ERRORF (errorKey, "fork failed with errno: %s", strerror (errno));
closePipe (pipe_stdin);
closePipe (pipe_stdout);
closePipe (pipe_stderr);
Expand Down Expand Up @@ -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_GENERAL_RESOURCE_ERROR (errorKey, "The communication with the GPG process failed.");
closePipe (pipe_stdin);
closePipe (pipe_stdout);
closePipe (pipe_stderr);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/csvstorage/csvstorage.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ static int csvRead (KeySet * returned, Key * parentKey, char delim, Key * colAsP
FILE * fp = fopen (fileName, "rb");
if (!fp)
{
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "couldn't open file %s", fileName);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "couldn't open file %s", fileName);
return -1;
}
int lastLine = 0;
Expand Down
24 changes: 12 additions & 12 deletions src/plugins/curlget/curlget.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ int elektraCurlgetGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA

if (fd == -1)
{
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading", data->path);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading", data->path);
return -1;
}
FILE * fp = fetchFile (data, fd);
Expand All @@ -632,12 +632,12 @@ int elektraCurlgetGet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA
fp = fopen (data->path, "rb");
if (fp && data->useLocalCopy)
{
ELEKTRA_ADD_RESOURCE_WARNINGF (parentKey, "Failed to fetch configuration from %s, falling back to local copy %s\n",
ELEKTRA_ADD_GENERAL_RESOURCE_WARNINGF (parentKey, "Failed to fetch configuration from %s, falling back to local copy %s\n",
data->getUrl, data->path);
}
else
{
ELEKTRA_SET_RESOURCE_ERROR (parentKey, "Failed to read configuration\n");
ELEKTRA_SET_GENERAL_RESOURCE_ERROR (parentKey, "Failed to read configuration\n");
return -1;
}
}
Expand Down Expand Up @@ -733,7 +733,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA
else
{
close (fd);
ELEKTRA_SET_RESOURCE_ERRORF (parentKey,
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey,
"Failed to fetch configuration from %s. Aborting because consistency can't be ensured",
data->getUrl);
if (data->tmpFile) unlink (data->tmpFile);
Expand Down Expand Up @@ -763,7 +763,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA
fp = fopen (tmpFile, "rb");
if (!fp)
{
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading", tmpFile);
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "Failed to open %s for reading", tmpFile);
return -1;
}
fseek (fp, 0L, SEEK_END);
Expand Down Expand Up @@ -817,7 +817,7 @@ int elektraCurlgetSet (Plugin * handle ELEKTRA_UNUSED, KeySet * returned ELEKTRA
if (res != CURLE_OK)
{

ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (HTTP POST) failed: %s\n",
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "curl upload (HTTP POST) failed: %s\n",
curl_easy_strerror (res));
retval = -1;
}
Expand All @@ -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_GENERAL_RESOURCE_ERRORF (parentKey, "curl upload (HTTP PUT) failed: %s",
curl_easy_strerror (res));
retval = -1;
}
Expand All @@ -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_GENERAL_RESOURCE_ERRORF (parentKey, "curl upload (HTTP PUT) failed: %s",
curl_easy_strerror (res));
retval = -1;
}
Expand Down Expand Up @@ -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_GENERAL_RESOURCE_ERRORF (parentKey, "curl upload (FTP PUT) failed: %s",
curl_easy_strerror (res));
retval = -1;
}
Expand All @@ -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_GENERAL_RESOURCE_ERRORF (parentKey, "curl upload (SCP) failed: %s",
curl_easy_strerror (res));
else if (data->putProto == PROTO_SFTP)
ELEKTRA_SET_RESOURCE_ERRORF (parentKey, "curl upload (SFTP) failed: %s",
ELEKTRA_SET_GENERAL_RESOURCE_ERRORF (parentKey, "curl upload (SFTP) failed: %s",
curl_easy_strerror (res));
retval = -1;
}
Expand All @@ -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_GENERAL_RESOURCE_ERRORF (parentKey, "curl upload (default) failed: %s",
curl_easy_strerror (res));
retval = -1;
}
Expand Down
Loading

0 comments on commit 75ceb83

Please sign in to comment.