From 2a35f8a2f77d5a95e22eb45e0fe3b6dd0c23d131 Mon Sep 17 00:00:00 2001 From: Alina Lenk Date: Wed, 17 Apr 2024 23:56:01 +0200 Subject: [PATCH] Add nonnull attribute to dio_get_*_json() dest pointer See RM #465 Signed-off-by: Alina Lenk --- common/networking/dataio_json.c | 35 ------------------- common/networking/dataio_json.h | 60 ++++++++++++++++++++++----------- 2 files changed, 40 insertions(+), 55 deletions(-) diff --git a/common/networking/dataio_json.c b/common/networking/dataio_json.c index 53d064d1e0..e828160fdc 100644 --- a/common/networking/dataio_json.c +++ b/common/networking/dataio_json.c @@ -414,11 +414,6 @@ static bool dio_get_uint8_json_internal(json_t *json_packet, } *dest = json_integer_value(pint); - if (!dest) { - log_error("ERROR: Unable to get unit8 from location: %s", plocation_name(location)); - return FALSE; - } - return TRUE; } @@ -449,11 +444,6 @@ bool dio_get_uint16_json(struct connection *pc, struct data_in *din, return FALSE; } *dest = json_integer_value(pint); - - if (!dest) { - log_error("ERROR: Unable to get unit16 from location: %s", plocation_name(location)); - return FALSE; - } } else { return dio_get_uint16_raw(din, dest); } @@ -476,11 +466,6 @@ static bool dio_get_uint32_json_internal(json_t *json_packet, } *dest = json_integer_value(pint); - if (!dest) { - log_error("ERROR: Unable to get unit32 from location: %s", plocation_name(location)); - return FALSE; - } - return TRUE; } @@ -1215,11 +1200,6 @@ static bool dio_get_bool8_json_internal(json_t *json_packet, } *dest = json_is_true(pbool); - if (!dest) { - log_error("ERROR: Unable to get bool from location: %s", plocation_name(location)); - return FALSE; - } - return TRUE; } @@ -1250,11 +1230,6 @@ bool dio_get_bool32_json(struct connection *pc, struct data_in *din, return FALSE; } *dest = json_is_true(pbool); - - if (!dest) { - log_error("ERROR: Unable to get bool32 from location: %s", plocation_name(location)); - return FALSE; - } } else { return dio_get_bool32_raw(din, dest); } @@ -1320,11 +1295,6 @@ bool dio_get_sint8_json(struct connection *pc, struct data_in *din, return FALSE; } *dest = json_integer_value(pint); - - if (!dest) { - log_error("ERROR: Unable to get sint8 from location: %s", plocation_name(location)); - return FALSE; - } } else { return dio_get_sint8_raw(din, dest); } @@ -1346,11 +1316,6 @@ bool dio_get_sint16_json(struct connection *pc, struct data_in *din, return FALSE; } *dest = json_integer_value(pint); - - if (!dest) { - log_error("ERROR: Unable to get sint16 from location: %s", plocation_name(location)); - return FALSE; - } } else { return dio_get_sint16_raw(din, dest); } diff --git a/common/networking/dataio_json.h b/common/networking/dataio_json.h index 86c1da9199..e74140ad95 100644 --- a/common/networking/dataio_json.h +++ b/common/networking/dataio_json.h @@ -41,60 +41,80 @@ bool dio_get_type_json(struct data_in *din, enum data_type type, int *dest) fc__attribute((nonnull (3))); bool dio_get_uint8_json(struct connection *pc, struct data_in *din, - const struct plocation *location, int *dest); + const struct plocation *location, int *dest) + fc__attribute((nonnull (4))); bool dio_get_uint16_json(struct connection *pc, struct data_in *din, - const struct plocation *location, int *dest); + const struct plocation *location, int *dest) + fc__attribute((nonnull (4))); bool dio_get_uint32_json(struct connection *pc, struct data_in *din, - const struct plocation *location, int *dest); + const struct plocation *location, int *dest) + fc__attribute((nonnull (4))); bool dio_get_sint8_json(struct connection *pc, struct data_in *din, - const struct plocation *location, int *dest); + const struct plocation *location, int *dest) + fc__attribute((nonnull (4))); bool dio_get_sint16_json(struct connection *pc, struct data_in *din, - const struct plocation *location, int *dest); + const struct plocation *location, int *dest) + fc__attribute((nonnull (4))); bool dio_get_sint32_json(struct connection *pc, struct data_in *din, - const struct plocation *location, int *dest); + const struct plocation *location, int *dest) + fc__attribute((nonnull (4))); bool dio_get_bool8_json(struct connection *pc, struct data_in *din, - const struct plocation *location, bool *dest); + const struct plocation *location, bool *dest) + fc__attribute((nonnull (4))); bool dio_get_bool32_json(struct connection *pc, struct data_in *din, - const struct plocation *location, bool *dest); + const struct plocation *location, bool *dest) + fc__attribute((nonnull (4))); bool dio_get_ufloat_json(struct connection *pc, struct data_in *din, const struct plocation *location, - float *dest, int float_factor); + float *dest, int float_factor) + fc__attribute((nonnull (4))); bool dio_get_sfloat_json(struct connection *pc, struct data_in *din, const struct plocation *location, - float *dest, int float_factor); + float *dest, int float_factor) + fc__attribute((nonnull (4))); bool dio_get_memory_json(struct connection *pc, struct data_in *din, struct plocation *location, - void *dest, size_t dest_size); + void *dest, size_t dest_size) + fc__attribute((nonnull (4))); bool dio_get_string_json(struct connection *pc, struct data_in *din, const struct plocation *location, - char *dest, size_t max_dest_size); + char *dest, size_t max_dest_size) + fc__attribute((nonnull (4))); bool dio_get_estring_json(struct connection *pc, struct data_in *din, const struct plocation *location, - char *dest, size_t max_dest_size); + char *dest, size_t max_dest_size) + fc__attribute((nonnull (4))); bool dio_get_cm_parameter_json(struct connection *pc, struct data_in *din, struct plocation *location, - struct cm_parameter *param); + struct cm_parameter *param) + fc__attribute((nonnull (4))); bool dio_get_worklist_json(struct connection *pc, struct data_in *din, struct plocation *location, - struct worklist *pwl); + struct worklist *pwl) + fc__attribute((nonnull (4))); bool dio_get_unit_order_json(struct connection *pc, struct data_in *din, struct plocation *location, - struct unit_order *order); + struct unit_order *order) + fc__attribute((nonnull (4))); bool dio_get_requirement_json(struct connection *pc, struct data_in *din, const struct plocation *location, - struct requirement *preq); + struct requirement *preq) + fc__attribute((nonnull (4))); bool dio_get_action_probability_json(struct connection *pc, struct data_in *din, const struct plocation *location, - struct act_prob *prob); + struct act_prob *prob) + fc__attribute((nonnull (4))); bool dio_get_uint8_vec8_json(struct connection *pc, struct data_in *din, const struct plocation *location, - int **values, int stop_value); + int **values, int stop_value) + fc__attribute((nonnull (4))); bool dio_get_uint16_vec8_json(struct connection *pc, struct data_in *din, const struct plocation *location, - int **values, int stop_value); + int **values, int stop_value) + fc__attribute((nonnull (4))); /* Should be a function but we need some macro magic. */ #define DIO_BV_GET(pdin, location, bv) \ -- 2.34.1