Skip to content

Commit

Permalink
Revert "fix oclint errors"
Browse files Browse the repository at this point in the history
This reverts commit 8703b05.
  • Loading branch information
kodebach committed Oct 2, 2020
1 parent 5865fa6 commit 25a788e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 17 deletions.
15 changes: 5 additions & 10 deletions src/libs/ease/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,8 @@ int elektraArrayValidateName (const Key * key)
int elektraArrayValidateBaseNameString (const char * baseName)
{
const char * current = baseName;
if (current == NULL || *current != '#')
{
return -1;
}
if (strcmp (current, "#") != 0)
{
return 0;
}
if (!current || *current != '#') return -1;
if (!strcmp (current, "#")) return 0;

current++;
int underscores = 0;
Expand All @@ -74,7 +68,8 @@ int elektraArrayValidateBaseNameString (const char * baseName)
digits++;
}

if (underscores != digits - 1 || underscores + digits > ELEKTRA_MAX_ARRAY_SIZE - 2)
if (underscores != digits - 1) return -1;
if (underscores + digits > ELEKTRA_MAX_ARRAY_SIZE - 2)
{
return -1;
}
Expand Down Expand Up @@ -150,7 +145,7 @@ int elektraArrayIncName (Key * key)

kdb_long_long_t oldIndex = 0;
if (offsetIndex && elektraReadArrayNumber (baseName, &oldIndex) == -1) return -1;
kdb_long_long_t newIndex = offsetIndex == 0 ? 0 : oldIndex + 1; // we increment by one or use 0 if the name contains no index yet
kdb_long_long_t newIndex = offsetIndex != 0 ? oldIndex + 1 : 0; // we increment by one or use 0 if the name contains no index yet

char newName[ELEKTRA_MAX_ARRAY_SIZE];

Expand Down
8 changes: 4 additions & 4 deletions src/plugins/ccode/coder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ void Coder::decodeValue (CppKey & key)
CppKey Coder::encodeName (CppKey const & key)
{
CppKey escaped{ key.dup () };
auto namespace = key.getNamespace ();
escaped.setName (namespace == "/" ? "/" : namespace + ":/");
auto ns = key.getNamespace ();
escaped.setName (ns == "/" ? "/" : ns + ":/");
auto keyIterator = key.begin ();

while (++keyIterator != key.end ())
Expand All @@ -199,8 +199,8 @@ CppKey Coder::encodeName (CppKey const & key)
CppKey Coder::decodeName (CppKey const & key)
{
CppKey unescaped{ key.dup () };
auto namespace = key.getNamespace ();
unescaped.setName (namespace == "/" ? "/" : namespace + ":/");
auto ns = key.getNamespace ();
unescaped.setName (ns == "/" ? "/" : ns + ":/");
auto keyIterator = key.begin ();

while (++keyIterator != key.end ())
Expand Down
6 changes: 3 additions & 3 deletions src/plugins/ccode/testmod_ccode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ CppKeySet percentConfig ()

void testEnocdingDecoding (Plugin * const plugin, CppKey const & parent, string const decodedString, string const encodedString = "")
{
ckdb::KeySet * rawKeys = ksNew (20, keyNew ("user:/tests/ccode/key", KEY_VALUE, decodedString.c_str (), KEY_END), KS_END);
succeed_if_same (plugin->kdbSet (plugin, rawKeys, *parent), //! OCLint (empty if, too few branches switch)
ckdb::KeySet * ks = ksNew (20, keyNew ("user:/tests/ccode/key", KEY_VALUE, decodedString.c_str (), KEY_END), KS_END);
succeed_if_same (plugin->kdbSet (plugin, ks, *parent), //! OCLint (empty if, too few branches switch)
ELEKTRA_PLUGIN_STATUS_SUCCESS, "Call of `kdbset` was not successful");

CppKeySet keys (rawKeys);
CppKeySet keys (ks);

if (!encodedString.empty ())
{
Expand Down

0 comments on commit 25a788e

Please sign in to comment.