aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mds-base.h5
-rw-r--r--src/mds-clipboard.c1
-rw-r--r--src/mds-clipboard.h4
-rw-r--r--src/mds-kkbd.c11
-rw-r--r--src/mds-kkbd.h12
-rw-r--r--src/mds-registry/registry.c4
-rw-r--r--src/mds-registry/slave.c7
-rw-r--r--src/mds-registry/slave.h40
-rw-r--r--src/mds-server/client.h11
-rw-r--r--src/mds-server/interception-condition.h8
-rw-r--r--src/mds-server/interceptors.c1
-rw-r--r--src/mds-server/interceptors.h6
-rw-r--r--src/mds-server/mds-server.c1
-rw-r--r--src/mds-server/mds-server.h4
-rw-r--r--src/mds-server/multicast.h10
-rw-r--r--src/mds-server/queued-interception.h8
-rw-r--r--src/mds-server/receiving.c4
-rw-r--r--src/mds-server/receiving.h1
-rw-r--r--src/mds-server/sending.c2
-rw-r--r--src/mds-server/sending.h3
-rw-r--r--src/mds-server/slavery.h2
-rw-r--r--src/mds.c1
-rw-r--r--src/mds.h7
23 files changed, 118 insertions, 35 deletions
diff --git a/src/mds-base.h b/src/mds-base.h
index 50aba78..8def600 100644
--- a/src/mds-base.h
+++ b/src/mds-base.h
@@ -286,7 +286,8 @@ extern int postinitialise_server(void);
*
* @return The number of bytes that will be stored by `marshal_server`
*/
-extern size_t marshal_server_size(void) __attribute__((pure));
+__attribute__((pure))
+extern size_t marshal_server_size(void);
/**
* This function should be implemented by the actual server implementation
@@ -296,6 +297,7 @@ extern size_t marshal_server_size(void) __attribute__((pure));
* @param state_buf The buffer for the marshalled data
* @return Non-zero on error
*/
+__attribute__((nonnull))
extern int marshal_server(char* state_buf);
/**
@@ -310,6 +312,7 @@ extern int marshal_server(char* state_buf);
* @param state_buf The marshalled data that as not been read already
* @return Non-zero on error
*/
+__attribute__((nonnull))
extern int unmarshal_server(char* state_buf);
/**
diff --git a/src/mds-clipboard.c b/src/mds-clipboard.c
index ee3706f..e57b6cf 100644
--- a/src/mds-clipboard.c
+++ b/src/mds-clipboard.c
@@ -505,6 +505,7 @@ int handle_message(void)
*
* @param entry The clipboard entry to free
*/
+__attribute__((nonnull))
static inline void free_clipboard_entry(clipitem_t* entry)
{
if (entry->autopurge == CLIPITEM_AUTOPURGE_NEVER)
diff --git a/src/mds-clipboard.h b/src/mds-clipboard.h
index 7d9d6bf..b71344c 100644
--- a/src/mds-clipboard.h
+++ b/src/mds-clipboard.h
@@ -109,6 +109,7 @@ int clipboard_danger(void);
* @param recv_client_id The ID of the client
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
int clipboard_death(const char* recv_client_id);
/**
@@ -119,6 +120,7 @@ int clipboard_death(const char* recv_client_id);
* @param recv_client_id The ID of the client
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
int clipboard_add(int level, const char* time_to_live, const char* recv_client_id);
/**
@@ -130,6 +132,7 @@ int clipboard_add(int level, const char* time_to_live, const char* recv_client_i
* @param recv_message_id The message ID of the received message
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
int clipboard_read(int level, size_t index, const char* recv_client_id, const char* recv_message_id);
/**
@@ -157,6 +160,7 @@ int clipboard_set_size(int level, size_t size);
* @param recv_message_id The message ID of the received message
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
int clipboard_get_size(int level, const char* recv_client_id, const char* recv_message_id);
diff --git a/src/mds-kkbd.c b/src/mds-kkbd.c
index 3319c87..d8edde2 100644
--- a/src/mds-kkbd.c
+++ b/src/mds-kkbd.c
@@ -889,8 +889,7 @@ int handle_keyboard_enumeration(const char* recv_modify_id)
* @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
-int handle_set_keyboard_leds(const char* recv_active, const char* recv_mask,
- const char* recv_keyboard)
+int handle_set_keyboard_leds(const char* recv_active, const char* recv_mask, const char* recv_keyboard)
{
int active = 0;
int mask = 0;
@@ -962,8 +961,7 @@ int handle_set_keyboard_leds(const char* recv_active, const char* recv_mask,
* @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
-int handle_get_keyboard_leds(const char* recv_client_id, const char* recv_message_id,
- const char* recv_keyboard)
+int handle_get_keyboard_leds(const char* recv_client_id, const char* recv_message_id, const char* recv_keyboard)
{
uint32_t msgid;
size_t n;
@@ -1032,6 +1030,7 @@ int handle_get_keyboard_leds(const char* recv_client_id, const char* recv_messag
* @param name The name of the LED
* @return The value of the LED
*/
+__attribute__((nonnull))
static int parse_led(const char* name)
{
if (strequals(name, "num")) return LED_NUM_LOCK;
@@ -1051,6 +1050,7 @@ static int parse_led(const char* name)
* @param position The new position of the LED, either zero-based index
* or name of the original LED with that position
*/
+__attribute__((nonnull))
static void remap_led(const char* name, const char* position)
{
int* leds[] = { [LED_NUM_LOCK] = &led_num_lock,
@@ -1188,6 +1188,7 @@ int handle_map_keyboard_leds(const char* recv_keyboard)
* @param out Output parameter for the keycode's new mapping
* @return -1 on error, 1 if parsed, 0 if the line is empty
*/
+__attribute__((nonnull(1, 4, 5)))
static int parse_remap_line(char* begin, char* end, size_t n, int* restrict in, int* restrict out)
{
static char buf[3 * sizeof(int) + 1];
@@ -1259,6 +1260,7 @@ static int add_mapping(int in, int out)
* @param n The size of `table`
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
static int remap(char* table, size_t n)
{
char* begin = table;
@@ -1307,6 +1309,7 @@ static int remap(char* table, size_t n)
* @param recv_message_id The value of the `Message ID`-header
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
static int mapping_query(const char* recv_client_id, const char* recv_message_id)
{
size_t top = 64 + 3 * sizeof(size_t), n = 0, off, i;
diff --git a/src/mds-kkbd.h b/src/mds-kkbd.h
index 8037e83..f0454ea 100644
--- a/src/mds-kkbd.h
+++ b/src/mds-kkbd.h
@@ -46,6 +46,7 @@ int handle_message(void);
* @param recv_modify_id The value of the `Modify ID`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull(1, 2)))
int handle_enumerate_keyboards(const char* recv_client_id, const char* recv_message_id,
const char* recv_modify_id);
@@ -67,8 +68,7 @@ int handle_keyboard_enumeration(const char* recv_modify_id);
* @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
-int handle_set_keyboard_leds(const char* recv_active, const char* recv_mask,
- const char* recv_keyboard);
+int handle_set_keyboard_leds(const char* recv_active, const char* recv_mask, const char* recv_keyboard);
/**
* Handle the received message after it has been
@@ -79,8 +79,8 @@ int handle_set_keyboard_leds(const char* recv_active, const char* recv_mask,
* @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
-int handle_get_keyboard_leds(const char* recv_client_id, const char* recv_message_id,
- const char* recv_keyboard);
+__attribute__((nonnull(1, 2)))
+int handle_get_keyboard_leds(const char* recv_client_id, const char* recv_message_id, const char* recv_keyboard);
/**
* Handle the received message after it has been
@@ -101,6 +101,7 @@ int handle_map_keyboard_leds(const char* recv_keyboard);
* @param recv_keyboard The value of the `Keyboard`-header, `NULL` if omitted
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull(1, 2)))
int handle_keycode_map(const char* recv_client_id, const char* recv_message_id,
const char* recv_action, const char* recv_keyboard);
@@ -112,6 +113,7 @@ int handle_keycode_map(const char* recv_client_id, const char* recv_message_id,
* that position; delimited by an equals-sign
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
int remap_led_cmdline(char* arg);
/**
@@ -160,6 +162,7 @@ void close_input(void);
* @param trio Whether the scancode has three integers rather than one
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
int send_key(int* restrict scancode, int trio);
/**
@@ -177,6 +180,7 @@ int fetch_keys(void);
* @param recv_message_id The message ID of the message the client sent
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
int send_errno(int error, const char* recv_client_id, const char* recv_message_id);
/**
diff --git a/src/mds-registry/registry.c b/src/mds-registry/registry.c
index 53b905b..334d97d 100644
--- a/src/mds-registry/registry.c
+++ b/src/mds-registry/registry.c
@@ -134,6 +134,7 @@ static int handle_close_message(void)
* @param client The ID of the client that implements the server-side of the protocol
* @return Non-zero on error
*/
+__attribute__((nonnull))
static int registry_action_add(int has_key, char* command, size_t command_key, uint64_t client)
{
int saved_errno;
@@ -221,6 +222,7 @@ static void registry_action_remove(size_t command_key, uint64_t client)
* @param wait_set Table to fill with missing protocols if `action == 0`
* @return Non-zero on error
*/
+__attribute__((nonnull))
static int registry_action_act(char* command, int action, uint64_t client, hash_table_t* wait_set)
{
size_t command_key = (size_t)(void*)command;
@@ -268,6 +270,7 @@ static int registry_action_act(char* command, int action, uint64_t client, hash_
* @return Zero on success -1 on error or interruption,
* `errno` will be set accordingly
*/
+__attribute__((nonnull))
static int registry_action(size_t length, int action, const char* recv_client_id, const char* recv_message_id)
{
char* payload = received.payload;
@@ -343,6 +346,7 @@ static int registry_action(size_t length, int action, const char* recv_client_id
* @return Zero on success, -1 on error or interruption,
* `errno` will be set accordingly
*/
+__attribute__((nonnull))
static int list_registry(const char* recv_client_id, const char* recv_message_id)
{
size_t ptr = 0, i;
diff --git a/src/mds-registry/slave.c b/src/mds-registry/slave.c
index a2f4005..7376b0c 100644
--- a/src/mds-registry/slave.c
+++ b/src/mds-registry/slave.c
@@ -38,6 +38,7 @@
* @param slave The slave
* @return Non-zero, `errno` will be set accordingly
*/
+__attribute__((nonnull))
static int slave_notify_client(slave_t* slave)
{
char buf[sizeof("To: %s\nIn response to: %s\nMessage ID: %" PRIu32 "\nOrigin command: register\n\n")
@@ -167,7 +168,8 @@ int start_created_slave(slave_t* restrict slave)
* @param recv_message_id The ID of the message that triggered the waiting
* @return Non-zero on error
*/
-int start_slave(hash_table_t* restrict wait_set, const char* restrict recv_client_id, const char* restrict recv_message_id)
+int start_slave(hash_table_t* restrict wait_set, const char* restrict recv_client_id,
+ const char* restrict recv_message_id)
{
slave_t* slave = slave_create(wait_set, recv_client_id, recv_message_id);
size_t slave_address, i;
@@ -273,7 +275,8 @@ int advance_slaves(char* command)
* @param recv_message_id The ID of the message that triggered the waiting
* @return The slave, `NULL` on error, `errno` will be set accordingly
*/
-slave_t* slave_create(hash_table_t* restrict wait_set, const char* restrict recv_client_id, const char* restrict recv_message_id)
+slave_t* slave_create(hash_table_t* restrict wait_set, const char* restrict recv_client_id,
+ const char* restrict recv_message_id)
{
slave_t* restrict rc = NULL;
int saved_errno;
diff --git a/src/mds-registry/slave.h b/src/mds-registry/slave.h
index 59183ea..1213aaa 100644
--- a/src/mds-registry/slave.h
+++ b/src/mds-registry/slave.h
@@ -87,6 +87,15 @@ typedef struct slave
/**
+ * Start a slave thread with an already created slave
+ *
+ * @param slave The slave
+ * @return Non-zero on error, `errno` will be set accordingly
+ */
+__attribute__((nonnull))
+int start_created_slave(slave_t* restrict slave);
+
+/**
* Start a slave thread
*
* @param wait_set Set of protocols for which to wait that they become available
@@ -94,15 +103,9 @@ typedef struct slave
* @param recv_message_id The ID of the message that triggered the waiting
* @return Non-zero on error
*/
-int start_slave(hash_table_t* restrict wait_set, const char* restrict recv_client_id, const char* restrict recv_message_id);
-
-/**
- * Start a slave thread with an already created slave
- *
- * @param slave The slave
- * @return Non-zero on error, `errno` will be set accordingly
- */
-int start_created_slave(slave_t* restrict slave);
+__attribute__((nonnull))
+int start_slave(hash_table_t* restrict wait_set, const char* restrict recv_client_id,
+ const char* restrict recv_message_id);
/**
* Close all slaves associated with a client
@@ -117,14 +120,20 @@ void close_slaves(uint64_t client);
* @param command The protocol
* @return Non-zero on error, `ernno`will be set accordingly
*/
+__attribute__((nonnull))
int advance_slaves(char* command);
/**
* Create a slave
*
- * @return The slave
+ * @param wait_set Set of protocols for which to wait that they become available
+ * @param recv_client_id The ID of the waiting client
+ * @param recv_message_id The ID of the message that triggered the waiting
+ * @return The slave, `NULL` on error, `errno` will be set accordingly
*/
-slave_t* slave_create(hash_table_t* restrict wait_set, const char* restrict recv_client_id, const char* restrict recv_message_id);
+__attribute__((nonnull))
+slave_t* slave_create(hash_table_t* restrict wait_set, const char* restrict recv_client_id,
+ const char* restrict recv_message_id);
/**
@@ -132,6 +141,7 @@ slave_t* slave_create(hash_table_t* restrict wait_set, const char* restrict recv
*
* @param this Memory slot in which to store the new slave information
*/
+__attribute__((nonnull))
void slave_initialise(slave_t* restrict this);
/**
@@ -147,7 +157,8 @@ void slave_destroy(slave_t* restrict this);
* @param this The slave information
* @return The number of bytes to allocate to the output buffer
*/
-size_t slave_marshal_size(const slave_t* restrict this) __attribute__((pure));
+__attribute__((pure, nonnull))
+size_t slave_marshal_size(const slave_t* restrict this);
/**
* Marshals slave information
@@ -156,6 +167,7 @@ size_t slave_marshal_size(const slave_t* restrict this) __attribute__((pure));
* @param data Output buffer for the marshalled data
* @return The number of bytes that have been written (everything will be written)
*/
+__attribute__((nonnull))
size_t slave_marshal(const slave_t* restrict this, char* restrict data);
/**
@@ -166,6 +178,7 @@ size_t slave_marshal(const slave_t* restrict this, char* restrict data);
* @return Zero on error, `errno` will be set accordingly, otherwise the
* number of read bytes. Destroy the slave information on error.
*/
+__attribute__((nonnull))
size_t slave_unmarshal(slave_t* restrict this, char* restrict data);
/**
@@ -174,7 +187,8 @@ size_t slave_unmarshal(slave_t* restrict this, char* restrict data);
* @param data In buffer with the marshalled data
* @return The number of read bytes
*/
-size_t slave_unmarshal_skip(char* restrict data) __attribute__((pure));
+__attribute__((pure, nonnull))
+size_t slave_unmarshal_skip(char* restrict data);
#endif
diff --git a/src/mds-server/client.h b/src/mds-server/client.h
index 24152f6..e60a0ed 100644
--- a/src/mds-server/client.h
+++ b/src/mds-server/client.h
@@ -154,6 +154,7 @@ typedef struct client
*
* @param this Memory slot in which to store the new client information
*/
+__attribute__((nonnull))
void client_initialise(client_t* restrict this);
/**
@@ -168,6 +169,7 @@ void client_initialise(client_t* restrict this);
* @param this The client information
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
int client_initialise_threading(client_t* restrict this);
/**
@@ -175,6 +177,7 @@ int client_initialise_threading(client_t* restrict this);
*
* @param this The client information
*/
+__attribute__((nonnull))
void client_destroy(client_t* restrict this);
/**
@@ -183,7 +186,8 @@ void client_destroy(client_t* restrict this);
* @param this The client information
* @return The number of bytes to allocate to the output buffer
*/
-size_t client_marshal_size(const client_t* restrict this) __attribute__((pure));
+__attribute__((pure, nonnull))
+size_t client_marshal_size(const client_t* restrict this);
/**
* Marshals client information
@@ -192,6 +196,7 @@ size_t client_marshal_size(const client_t* restrict this) __attribute__((pure));
* @param data Output buffer for the marshalled data
* @return The number of bytes that have been written (everything will be written)
*/
+__attribute__((nonnull))
size_t client_marshal(const client_t* restrict this, char* restrict data);
/**
@@ -202,6 +207,7 @@ size_t client_marshal(const client_t* restrict this, char* restrict data);
* @return Zero on error, `errno` will be set accordingly, otherwise the
* number of read bytes. Destroy the client information on error.
*/
+__attribute__((nonnull))
size_t client_unmarshal(client_t* restrict this, char* restrict data);
/**
@@ -210,7 +216,8 @@ size_t client_unmarshal(client_t* restrict this, char* restrict data);
* @param data In buffer with the marshalled data
* @return The number of read bytes
*/
-size_t client_unmarshal_skip(char* restrict data) __attribute__((pure));
+__attribute__((pure, nonnull))
+size_t client_unmarshal_skip(char* restrict data);
#endif
diff --git a/src/mds-server/interception-condition.h b/src/mds-server/interception-condition.h
index 006ae18..3e7c7e1 100644
--- a/src/mds-server/interception-condition.h
+++ b/src/mds-server/interception-condition.h
@@ -62,7 +62,8 @@ typedef struct interception_condition
* @param this The interception condition
* @return The number of bytes to allocate to the output buffer
*/
-size_t interception_condition_marshal_size(const interception_condition_t* restrict this) __attribute__((pure));
+__attribute__((pure, nonnull))
+size_t interception_condition_marshal_size(const interception_condition_t* restrict this);
/**
* Marshals an interception condition
@@ -71,6 +72,7 @@ size_t interception_condition_marshal_size(const interception_condition_t* restr
* @param data Output buffer for the marshalled data
* @return The number of bytes that have been written (everything will be written)
*/
+__attribute__((nonnull))
size_t interception_condition_marshal(const interception_condition_t* restrict this, char* restrict data);
/**
@@ -81,6 +83,7 @@ size_t interception_condition_marshal(const interception_condition_t* restrict t
* @return Zero on error, `errno` will be set accordingly, otherwise the
* number of read bytes. Destroy the interception condition on error.
*/
+__attribute__((nonnull))
size_t interception_condition_unmarshal(interception_condition_t* restrict this, char* restrict data);
/**
@@ -89,7 +92,8 @@ size_t interception_condition_unmarshal(interception_condition_t* restrict this,
* @param data In buffer with the marshalled data
* @return The number of read bytes
*/
-size_t interception_condition_unmarshal_skip(char* restrict data) __attribute__((pure));
+__attribute__((pure, nonnull))
+size_t interception_condition_unmarshal_skip(char* restrict data);
#endif
diff --git a/src/mds-server/interceptors.c b/src/mds-server/interceptors.c
index 9e66ce6..559a191 100644
--- a/src/mds-server/interceptors.c
+++ b/src/mds-server/interceptors.c
@@ -38,6 +38,7 @@
* @param client The intercepting client
* @param index The index of the condition
*/
+__attribute__((nonnull))
static void remove_intercept_condition(client_t* client, size_t index)
{
interception_condition_t* conds = client->interception_conditions;
diff --git a/src/mds-server/interceptors.h b/src/mds-server/interceptors.h
index 66aad42..5b8d50a 100644
--- a/src/mds-server/interceptors.h
+++ b/src/mds-server/interceptors.h
@@ -36,6 +36,7 @@
* @param modifying Whether the client may modify the messages
* @param stop Whether the condition should be removed rather than added
*/
+__attribute__((nonnull))
void add_intercept_condition(client_t* client, char* condition, int64_t priority, int modifying, int stop);
@@ -49,8 +50,9 @@ void add_intercept_condition(client_t* client, char* condition, int64_t priority
* @param count The number of accepted patterns
* @return Evaluates to true if and only if a matching pattern was found
*/
+__attribute__((pure, nonnull(1)))
int is_condition_matching(interception_condition_t* cond, size_t* hashes,
- char** keys, char** headers, size_t count) __attribute__((pure));
+ char** keys, char** headers, size_t count);
/**
@@ -64,6 +66,7 @@ int is_condition_matching(interception_condition_t* cond, size_t* hashes,
* @param interception_out Storage slot for found interception
* @return -1 on error, otherwise: evalutes to true iff a matching condition was found
*/
+__attribute__((pure, nonnull(1, 6)))
int find_matching_condition(client_t* client, size_t* hashes, char** keys, char** headers,
size_t count, queued_interception_t* interception_out);
@@ -79,6 +82,7 @@ int find_matching_condition(client_t* client, size_t* hashes, char** keys, char*
* @param interceptions_count_out Slot at where to store the number of found interceptors
* @return The found interceptors, `NULL` on error
*/
+__attribute__((pure, nonnull(1, 6)))
queued_interception_t* get_interceptors(client_t* sender, size_t* hashes, char** keys, char** headers,
size_t count, size_t* interceptions_count_out);
diff --git a/src/mds-server/mds-server.c b/src/mds-server/mds-server.c
index 801e47c..c249236 100644
--- a/src/mds-server/mds-server.c
+++ b/src/mds-server/mds-server.c
@@ -371,6 +371,7 @@ void* slave_loop(void* data)
* @param b:const queued_interception_t* The other of the two interceptors
* @return Negative if a before b, positive if a after b, otherwise zero
*/
+__attribute__((nonnull))
static int cmp_queued_interception(const void* a, const void* b)
{
const queued_interception_t* p = b; /* Highest first, so swap them. */
diff --git a/src/mds-server/mds-server.h b/src/mds-server/mds-server.h
index 471eb34..42b610a 100644
--- a/src/mds-server/mds-server.h
+++ b/src/mds-server/mds-server.h
@@ -46,6 +46,7 @@ void* slave_loop(void* data);
* @param length The length of the message
* @param sender The original sender of the message
*/
+__attribute__((nonnull))
void queue_message_multicast(char* message, size_t length, client_t* sender);
/**
@@ -53,7 +54,8 @@ void queue_message_multicast(char* message, size_t length, client_t* sender);
*
* @param args The arguments to the child process
*/
-void run_initrc(char** args) __attribute__((noreturn));
+__attribute__((noreturn, nonnull))
+void run_initrc(char** args);
#endif
diff --git a/src/mds-server/multicast.h b/src/mds-server/multicast.h
index a0add4d..bb83687 100644
--- a/src/mds-server/multicast.h
+++ b/src/mds-server/multicast.h
@@ -72,6 +72,7 @@ typedef struct multicast
*
* @param this The message multicast state
*/
+__attribute__((nonnull))
void multicast_initialise(multicast_t* restrict this);
/**
@@ -79,6 +80,7 @@ void multicast_initialise(multicast_t* restrict this);
*
* @param this The message multicast state
*/
+__attribute__((nonnull))
void multicast_destroy(multicast_t* restrict this);
/**
@@ -87,7 +89,8 @@ void multicast_destroy(multicast_t* restrict this);
* @param this The client information
* @return The number of bytes to allocate to the output buffer
*/
-size_t multicast_marshal_size(const multicast_t* restrict this) __attribute__((pure));
+__attribute__((pure, nonnull))
+size_t multicast_marshal_size(const multicast_t* restrict this);
/**
* Marshals a message multicast state
@@ -96,6 +99,7 @@ size_t multicast_marshal_size(const multicast_t* restrict this) __attribute__((p
* @param data Output buffer for the marshalled data
* @return The number of bytes that have been written (everything will be written)
*/
+__attribute__((nonnull))
size_t multicast_marshal(const multicast_t* restrict this, char* restrict data);
/**
@@ -106,6 +110,7 @@ size_t multicast_marshal(const multicast_t* restrict this, char* restrict data);
* @return Zero on error, `errno` will be set accordingly, otherwise the
* number of read bytes. Destroy the message multicast state on error.
*/
+__attribute__((nonnull))
size_t multicast_unmarshal(multicast_t* restrict this, char* restrict data);
/**
@@ -114,7 +119,8 @@ size_t multicast_unmarshal(multicast_t* restrict this, char* restrict data);
* @param data In buffer with the marshalled data
* @return The number of read bytes
*/
-size_t multicast_unmarshal_skip(char* restrict data) __attribute__((pure));
+__attribute__((pure, nonnull))
+size_t multicast_unmarshal_skip(char* restrict data);
diff --git a/src/mds-server/queued-interception.h b/src/mds-server/queued-interception.h
index 8162479..d03720a 100644
--- a/src/mds-server/queued-interception.h
+++ b/src/mds-server/queued-interception.h
@@ -60,7 +60,8 @@ typedef struct queued_interception
* @param this The client information
* @return The number of bytes to allocate to the output buffer
*/
-size_t queued_interception_marshal_size(void) __attribute__((const));
+__attribute__((const, nonnull))
+size_t queued_interception_marshal_size(void);
/**
* Marshals a queued interception
@@ -69,6 +70,7 @@ size_t queued_interception_marshal_size(void) __attribute__((const));
* @param data Output buffer for the marshalled data
* @return The number of bytes that have been written (everything will be written)
*/
+__attribute__((nonnull))
size_t queued_interception_marshal(const queued_interception_t* restrict this, char* restrict data);
/**
@@ -78,6 +80,7 @@ size_t queued_interception_marshal(const queued_interception_t* restrict this, c
* @param data In buffer with the marshalled data
* @return Zero on error, `errno` will be set accordingly, otherwise the number of read bytes.
*/
+__attribute__((nonnull))
size_t queued_interception_unmarshal(queued_interception_t* restrict this, char* restrict data);
/**
@@ -86,7 +89,8 @@ size_t queued_interception_unmarshal(queued_interception_t* restrict this, char*
* @param data In buffer with the marshalled data
* @return The number of read bytes
*/
-size_t queued_interception_unmarshal_skip(void) __attribute__((const));
+__attribute__((const, nonnull))
+size_t queued_interception_unmarshal_skip(void);
#endif
diff --git a/src/mds-server/receiving.c b/src/mds-server/receiving.c
index 28823f7..458aae4 100644
--- a/src/mds-server/receiving.c
+++ b/src/mds-server/receiving.c
@@ -39,6 +39,7 @@
* @param length The length of the message
* @param sender The original sender of the message
*/
+__attribute__((nonnull))
void queue_message_multicast(char* message, size_t length, client_t* sender);
@@ -50,6 +51,7 @@ void queue_message_multicast(char* message, size_t length, client_t* sender);
* @param modify_id The modify ID of the message
* @return Normally zero, but 1 if exited because of re-exec or termination
*/
+__attribute__((nonnull))
static int modifying_notify(client_t* client, mds_message_t message, uint64_t modify_id)
{
/* pthread_cond_timedwait is required to handle re-exec and termination because
@@ -110,6 +112,7 @@ static int modifying_notify(client_t* client, mds_message_t message, uint64_t mo
* @param stop Whether to stop listening rather than start or reconfigure
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull))
static int add_intercept_conditions_from_message(client_t* client, int modifying, int64_t priority, int stop)
{
int saved_errno;
@@ -174,6 +177,7 @@ static int add_intercept_conditions_from_message(client_t* client, int modifying
* @param message_id The message ID of the ID request
* @return Zero on success, -1 on error
*/
+__attribute__((nonnull(1)))
static int assign_and_send_id(client_t* client, const char* message_id)
{
char* msgbuf = NULL;
diff --git a/src/mds-server/receiving.h b/src/mds-server/receiving.h
index 7d704de..a38f611 100644
--- a/src/mds-server/receiving.h
+++ b/src/mds-server/receiving.h
@@ -29,6 +29,7 @@
* @param client The client whom sent the message
* @return Normally zero, but 1 if exited because of re-exec or termination
*/
+__attribute__((nonnull))
int message_received(client_t* client);
diff --git a/src/mds-server/sending.c b/src/mds-server/sending.c
index 1106d05..a02fb0e 100644
--- a/src/mds-server/sending.c
+++ b/src/mds-server/sending.c
@@ -57,6 +57,7 @@ static client_t* client_by_socket(int client_fd)
* @param modifying Whether the recipient may modify the message
* @return Evaluates to true if and only if the entire message was sent
*/
+__attribute__((nonnull))
static int send_multicast_to_recipient(multicast_t* multicast, client_t* recipient, int modifying)
{
char* msg = multicast->message + multicast->message_ptr;
@@ -93,6 +94,7 @@ static int send_multicast_to_recipient(multicast_t* multicast, client_t* recipie
* @param recipient The recipient
* @param modify_id The modify ID of the multicast
*/
+__attribute__((nonnull))
static void wait_for_reply(client_t* recipient, uint64_t modify_id)
{
/* pthread_cond_timedwait is required to handle re-exec and termination because
diff --git a/src/mds-server/sending.h b/src/mds-server/sending.h
index c31f31a..534c172 100644
--- a/src/mds-server/sending.h
+++ b/src/mds-server/sending.h
@@ -28,6 +28,7 @@
*
* @param multicast The multicast message
*/
+__attribute__((nonnull))
void multicast_message(multicast_t* multicast);
/**
@@ -35,6 +36,7 @@ void multicast_message(multicast_t* multicast);
*
* @param client The client
*/
+__attribute__((nonnull))
void send_multicast_queue(client_t* client);
/**
@@ -42,6 +44,7 @@ void send_multicast_queue(client_t* client);
*
* @param client The client
*/
+__attribute__((nonnull))
void send_reply_queue(client_t* client);
diff --git a/src/mds-server/slavery.h b/src/mds-server/slavery.h
index b613110..b65d978 100644
--- a/src/mds-server/slavery.h
+++ b/src/mds-server/slavery.h
@@ -30,6 +30,7 @@
* @param client The client
* @return Zero on success, -2 on failure, otherwise -1
*/
+__attribute__((nonnull))
int fetch_message(client_t* client);
/**
@@ -39,6 +40,7 @@ int fetch_message(client_t* client);
* @param slave_fd The file descriptor of the slave's socket
* @return Zero on success, -1 on error, error message will have been printed
*/
+__attribute__((nonnull))
int create_slave(pthread_t* thread_slot, int slave_fd);
/**
diff --git a/src/mds.c b/src/mds.c
index bcec1d9..d9a4c9c 100644
--- a/src/mds.c
+++ b/src/mds.c
@@ -295,6 +295,7 @@ pid_t parse_pid_t(const char* str, size_t n)
*
* @param child_args Command line arguments for the new image
*/
+__attribute__((nonnull))
static void exec_master_server(char** child_args)
{
/* Drop privileges. They most not be propagated non-authorised components. */
diff --git a/src/mds.h b/src/mds.h
index ae008fc..37cc699 100644
--- a/src/mds.h
+++ b/src/mds.h
@@ -29,6 +29,7 @@
* @param f The PID-file
* @return Whether the PID-file is not longer used
*/
+__attribute__((nonnull))
int is_pid_file_reusable(FILE* f);
/**
@@ -38,7 +39,8 @@ int is_pid_file_reusable(FILE* f);
* @param n The length of the string, excluding LF-termination
* @return The pid, `(pid_t)-1` if malformated
*/
-pid_t parse_pid_t(const char* str, size_t n) __attribute__((pure));
+__attribute__((pure, nonnull))
+pid_t parse_pid_t(const char* str, size_t n);
/**
* Start master server and respawn it if it crashes
@@ -54,6 +56,7 @@ int spawn_and_respawn_server(int fd);
* @param pathname The pathname of the directory to create
* @return Non-zero on error
*/
+__attribute__((nonnull))
int create_directory_root(const char* pathname);
/**
@@ -62,6 +65,7 @@ int create_directory_root(const char* pathname);
* @param pathname The pathname of the directory to create
* @return Non-zero on error
*/
+__attribute__((nonnull))
int create_directory_user(const char* pathname);
/**
@@ -70,6 +74,7 @@ int create_directory_user(const char* pathname);
* @param pathname The pathname of the directory to remove
* @return Non-zero on error
*/
+__attribute__((nonnull))
int unlink_recursive(const char* pathname);