summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOpenGnSys Support Team <soporte-og@soleta.eu>2021-06-10 17:04:46 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-06-10 17:05:07 +0200
commit87774ab087a55b9347acc0f89a38df408f209fb9 (patch)
treed7a08016db38a6d0b0fb40e0629b5426633986a6
parent88c8b52e8855fb26d6985cafeca77f2ae618fd97 (diff)
constify json parse helper function
json_t * parameter is not modified, constify to allow compiler to spew warnings in case the function tries to modify it.
-rw-r--r--src/json.c10
-rw-r--r--src/json.h10
2 files changed, 10 insertions, 10 deletions
diff --git a/src/json.c b/src/json.c
index 3765782..d693051 100644
--- a/src/json.c
+++ b/src/json.c
@@ -10,7 +10,7 @@
#include "json.h"
#include <stdint.h>
-int og_json_parse_string(json_t *element, const char **str)
+int og_json_parse_string(const json_t *element, const char **str)
{
if (json_typeof(element) != JSON_STRING)
return -1;
@@ -19,7 +19,7 @@ int og_json_parse_string(json_t *element, const char **str)
return 0;
}
-int og_json_parse_string_copy(json_t *element, char *str, size_t size)
+int og_json_parse_string_copy(const json_t *element, char *str, size_t size)
{
const char *reference_str;
int err = 0;
@@ -34,7 +34,7 @@ int og_json_parse_string_copy(json_t *element, char *str, size_t size)
return 0;
}
-int og_json_parse_uint64(json_t *element, uint64_t *integer)
+int og_json_parse_uint64(const json_t *element, uint64_t *integer)
{
if (json_typeof(element) != JSON_INTEGER)
return -1;
@@ -43,7 +43,7 @@ int og_json_parse_uint64(json_t *element, uint64_t *integer)
return 0;
}
-int og_json_parse_uint(json_t *element, uint32_t *integer)
+int og_json_parse_uint(const json_t *element, uint32_t *integer)
{
if (json_typeof(element) != JSON_INTEGER)
return -1;
@@ -52,7 +52,7 @@ int og_json_parse_uint(json_t *element, uint32_t *integer)
return 0;
}
-int og_json_parse_bool(json_t *element, bool *value)
+int og_json_parse_bool(const json_t *element, bool *value)
{
if (json_typeof(element) == JSON_TRUE)
*value = true;
diff --git a/src/json.h b/src/json.h
index 17e5698..1790d24 100644
--- a/src/json.h
+++ b/src/json.h
@@ -4,11 +4,11 @@
#include <jansson.h>
#include "schedule.h"
-int og_json_parse_string(json_t *element, const char **str);
-int og_json_parse_string_copy(json_t *element, char *str, size_t size);
-int og_json_parse_uint64(json_t *element, uint64_t *integer);
-int og_json_parse_uint(json_t *element, uint32_t *integer);
-int og_json_parse_bool(json_t *element, bool *value);
+int og_json_parse_string(const json_t *element, const char **str);
+int og_json_parse_string_copy(const json_t *element, char *str, size_t size);
+int og_json_parse_uint64(const json_t *element, uint64_t *integer);
+int og_json_parse_uint(const json_t *element, uint32_t *integer);
+int og_json_parse_bool(const json_t *element, bool *value);
#define OG_PARAM_PART_NUMBER (1UL << 0)
#define OG_PARAM_PART_CODE (1UL << 1)