mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
lib audit_logging: add _WARN_UNUSED_RESULT_
Have the compiler issue a warning when the return code from the API is ignored. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Wed Jul 25 09:28:31 CEST 2018 on sn-devel-144
This commit is contained in:
parent
6a5346f166
commit
a5e02f7264
@ -21,8 +21,9 @@
|
||||
#include <talloc.h>
|
||||
#include "lib/messaging/irpc.h"
|
||||
#include "lib/tsocket/tsocket.h"
|
||||
#include "lib/util/attr.h"
|
||||
|
||||
char* audit_get_timestamp(TALLOC_CTX *frame);
|
||||
_WARN_UNUSED_RESULT_ char *audit_get_timestamp(TALLOC_CTX *frame);
|
||||
void audit_log_human_text(const char *prefix,
|
||||
const char *message,
|
||||
int debug_class,
|
||||
@ -50,43 +51,48 @@ void audit_message_send(struct imessaging_context *msg_ctx,
|
||||
const char *server_name,
|
||||
uint32_t message_type,
|
||||
struct json_object *message);
|
||||
struct json_object json_new_object(void);
|
||||
struct json_object json_new_array(void);
|
||||
_WARN_UNUSED_RESULT_ struct json_object json_new_object(void);
|
||||
_WARN_UNUSED_RESULT_ struct json_object json_new_array(void);
|
||||
void json_free(struct json_object *object);
|
||||
void json_assert_is_array(struct json_object *array);
|
||||
bool json_is_invalid(struct json_object *object);
|
||||
_WARN_UNUSED_RESULT_ bool json_is_invalid(struct json_object *object);
|
||||
|
||||
int json_add_int(struct json_object *object, const char *name, const int value);
|
||||
int json_add_bool(struct json_object *object,
|
||||
const char *name,
|
||||
const bool value);
|
||||
int json_add_string(struct json_object *object,
|
||||
const char *name,
|
||||
const char *value);
|
||||
int json_add_object(struct json_object *object,
|
||||
const char *name,
|
||||
struct json_object *value);
|
||||
int json_add_stringn(struct json_object *object,
|
||||
const char *name,
|
||||
const char *value,
|
||||
const size_t len);
|
||||
int json_add_version(struct json_object *object, int major, int minor);
|
||||
int json_add_timestamp(struct json_object *object);
|
||||
int json_add_address(struct json_object *object,
|
||||
const char *name,
|
||||
const struct tsocket_address *address);
|
||||
int json_add_sid(struct json_object *object,
|
||||
const char *name,
|
||||
const struct dom_sid *sid);
|
||||
int json_add_guid(struct json_object *object,
|
||||
const char *name,
|
||||
const struct GUID *guid);
|
||||
_WARN_UNUSED_RESULT_ int json_add_int(struct json_object *object,
|
||||
const char *name,
|
||||
const int value);
|
||||
_WARN_UNUSED_RESULT_ int json_add_bool(struct json_object *object,
|
||||
const char *name,
|
||||
const bool value);
|
||||
_WARN_UNUSED_RESULT_ int json_add_string(struct json_object *object,
|
||||
const char *name,
|
||||
const char *value);
|
||||
_WARN_UNUSED_RESULT_ int json_add_object(struct json_object *object,
|
||||
const char *name,
|
||||
struct json_object *value);
|
||||
_WARN_UNUSED_RESULT_ int json_add_stringn(struct json_object *object,
|
||||
const char *name,
|
||||
const char *value,
|
||||
const size_t len);
|
||||
_WARN_UNUSED_RESULT_ int json_add_version(struct json_object *object,
|
||||
int major,
|
||||
int minor);
|
||||
_WARN_UNUSED_RESULT_ int json_add_timestamp(struct json_object *object);
|
||||
_WARN_UNUSED_RESULT_ int json_add_address(
|
||||
struct json_object *object,
|
||||
const char *name,
|
||||
const struct tsocket_address *address);
|
||||
_WARN_UNUSED_RESULT_ int json_add_sid(struct json_object *object,
|
||||
const char *name,
|
||||
const struct dom_sid *sid);
|
||||
_WARN_UNUSED_RESULT_ int json_add_guid(struct json_object *object,
|
||||
const char *name,
|
||||
const struct GUID *guid);
|
||||
|
||||
struct json_object json_get_array(struct json_object *object,
|
||||
const char* name);
|
||||
struct json_object json_get_object(struct json_object *object,
|
||||
const char* name);
|
||||
char *json_to_string(TALLOC_CTX *mem_ctx,
|
||||
struct json_object *object);
|
||||
_WARN_UNUSED_RESULT_ struct json_object json_get_array(
|
||||
struct json_object *object, const char *name);
|
||||
_WARN_UNUSED_RESULT_ struct json_object json_get_object(
|
||||
struct json_object *object, const char *name);
|
||||
_WARN_UNUSED_RESULT_ char *json_to_string(TALLOC_CTX *mem_ctx,
|
||||
struct json_object *object);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -604,6 +604,7 @@ static void test_json_to_string(void **state)
|
||||
{
|
||||
struct json_object object;
|
||||
char *s = NULL;
|
||||
int rc;
|
||||
|
||||
TALLOC_CTX *ctx = talloc_new(NULL);
|
||||
|
||||
@ -613,7 +614,8 @@ static void test_json_to_string(void **state)
|
||||
assert_string_equal("{}", s);
|
||||
TALLOC_FREE(s);
|
||||
|
||||
json_add_string(&object, "name", "value");
|
||||
rc = json_add_string(&object, "name", "value");
|
||||
assert_int_equal(0, rc);
|
||||
s = json_to_string(ctx, &object);
|
||||
assert_string_equal("{\"name\": \"value\"}", s);
|
||||
TALLOC_FREE(s);
|
||||
@ -641,6 +643,7 @@ static void test_json_get_array(void **state)
|
||||
json_t *o = NULL;
|
||||
struct json_object o1;
|
||||
struct json_object o2;
|
||||
int rc;
|
||||
|
||||
object = json_new_object();
|
||||
|
||||
@ -651,9 +654,12 @@ static void test_json_get_array(void **state)
|
||||
json_free(&array);
|
||||
|
||||
o1 = json_new_object();
|
||||
json_add_string(&o1, "value", "value-one");
|
||||
json_add_object(&stored_array, NULL, &o1);
|
||||
json_add_object(&object, "stored_array", &stored_array);
|
||||
rc = json_add_string(&o1, "value", "value-one");
|
||||
assert_int_equal(0, rc);
|
||||
rc = json_add_object(&stored_array, NULL, &o1);
|
||||
assert_int_equal(0, rc);
|
||||
rc = json_add_object(&object, "stored_array", &stored_array);
|
||||
assert_int_equal(0, rc);
|
||||
|
||||
array = json_get_array(&object, "stored_array");
|
||||
assert_true(array.valid);
|
||||
@ -679,11 +685,14 @@ static void test_json_get_array(void **state)
|
||||
array = json_get_array(&object, "stored_array");
|
||||
assert_true(json_is_array(array.root));
|
||||
o2 = json_new_object();
|
||||
json_add_string(&o2, "value", "value-two");
|
||||
rc = json_add_string(&o2, "value", "value-two");
|
||||
assert_int_equal(0, rc);
|
||||
assert_true(o2.valid);
|
||||
json_add_object(&array, NULL, &o2);
|
||||
rc = json_add_object(&array, NULL, &o2);
|
||||
assert_int_equal(0, rc);
|
||||
assert_true(json_is_array(array.root));
|
||||
json_add_object(&object, "stored_array", &array);
|
||||
rc = json_add_object(&object, "stored_array", &array);
|
||||
assert_int_equal(0, rc);
|
||||
assert_true(json_is_array(array.root));
|
||||
|
||||
array = json_get_array(&object, "stored_array");
|
||||
@ -728,6 +737,7 @@ static void test_json_get_object(void **state)
|
||||
struct json_object o2;
|
||||
struct json_object o3;
|
||||
json_t *value = NULL;
|
||||
int rc;
|
||||
|
||||
object = json_new_object();
|
||||
|
||||
@ -738,8 +748,10 @@ static void test_json_get_object(void **state)
|
||||
json_free(&o1);
|
||||
|
||||
o1 = json_new_object();
|
||||
json_add_string(&o1, "value", "value-one");
|
||||
json_add_object(&object, "stored_object", &o1);
|
||||
rc = json_add_string(&o1, "value", "value-one");
|
||||
assert_int_equal(0, rc);
|
||||
rc = json_add_object(&object, "stored_object", &o1);
|
||||
assert_int_equal(0, rc);
|
||||
|
||||
o2 = json_get_object(&object, "stored_object");
|
||||
assert_true(o2.valid);
|
||||
@ -752,9 +764,10 @@ static void test_json_get_object(void **state)
|
||||
|
||||
assert_string_equal("value-one", json_string_value(value));
|
||||
|
||||
json_add_string(&o2, "value", "value-two");
|
||||
json_add_object(&object, "stored_object", &o2);
|
||||
|
||||
rc = json_add_string(&o2, "value", "value-two");
|
||||
assert_int_equal(0, rc);
|
||||
rc = json_add_object(&object, "stored_object", &o2);
|
||||
assert_int_equal(0, rc);
|
||||
|
||||
o3 = json_get_object(&object, "stored_object");
|
||||
assert_true(o3.valid);
|
||||
|
Loading…
Reference in New Issue
Block a user