Skip to content

Commit 0338681

Browse files
committed
Add function attributes in various places
1 parent 7e155aa commit 0338681

File tree

5 files changed

+59
-24
lines changed

5 files changed

+59
-24
lines changed

audisp/audispd-llist.h

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "config.h"
2929
#include <sys/types.h>
3030
#include "audispd-pconfig.h"
31+
#include "gcc-attributes.h"
3132

3233
/* This is the node of the linked list. message & item are the only elements
3334
* at this time. Any data elements that are per item goes here. */
@@ -44,18 +45,34 @@ typedef struct {
4445
unsigned int cnt; // How many items in this list
4546
} conf_llist;
4647

47-
void plist_create(conf_llist *l);
48-
static inline void plist_first(conf_llist *l) { l->cur = l->head; }
49-
static inline unsigned int plist_count(conf_llist *l) { return l->cnt; }
50-
unsigned int plist_count_active(const conf_llist *l);
51-
void plist_last(conf_llist *l);
52-
lnode *plist_next(conf_llist *l);
53-
static inline lnode *plist_get_cur(conf_llist *l) { return l->cur; }
54-
int plist_append(conf_llist *l, plugin_conf_t *p);
55-
void plist_clear(conf_llist* l);
56-
void plist_mark_all_unchecked(conf_llist* l);
57-
lnode *plist_find_unchecked(conf_llist* l);
58-
lnode *plist_find_name(conf_llist* l, const char *name);
48+
void plist_create(conf_llist *l) __nonnull ((1));
49+
static inline void plist_first(conf_llist *l) __nonnull ((1));
50+
static inline unsigned int plist_count(conf_llist *l)
51+
__attribute_pure__ __nonnull ((1));
52+
unsigned int plist_count_active(const conf_llist *l) __nonnull ((1));
53+
void plist_last(conf_llist *l) __nonnull ((1));
54+
lnode *plist_next(conf_llist *l) __nonnull ((1));
55+
static inline lnode *plist_get_cur(conf_llist *l) __nonnull ((1));
56+
int plist_append(conf_llist *l, plugin_conf_t *p) __nonnull ((1));
57+
void plist_clear(conf_llist* l) __nonnull ((1));
58+
void plist_mark_all_unchecked(conf_llist* l) __nonnull ((1));
59+
lnode *plist_find_unchecked(conf_llist* l) __nonnull ((1));
60+
lnode *plist_find_name(conf_llist* l, const char *name) __nonnull ((1));
61+
62+
static inline void plist_first(conf_llist *l)
63+
{
64+
l->cur = l->head;
65+
}
66+
67+
static inline unsigned int plist_count(conf_llist *l)
68+
{
69+
return l->cnt;
70+
}
71+
72+
static inline lnode *plist_get_cur(conf_llist *l)
73+
{
74+
return l->cur;
75+
}
5976

6077
#endif
6178

audisp/audispd-pconfig.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <sys/types.h>
2828
#include "libaudit.h"
29+
#include "gcc-attributes.h"
2930

3031
typedef enum { A_NO, A_YES } active_t;
3132
typedef enum { S_ALWAYS, S_BUILTIN } service_t;
@@ -47,8 +48,9 @@ typedef struct plugin_conf
4748
unsigned restart_cnt; /* Number of times its crashed */
4849
} plugin_conf_t;
4950

50-
void clear_pconfig(plugin_conf_t *config);
51-
int load_pconfig(plugin_conf_t *config, int dirfd, char *file);
51+
void clear_pconfig(plugin_conf_t *config) __nonnull ((1));
52+
int load_pconfig(plugin_conf_t *config, int dirfd, char *file)
53+
__nonnull ((1, 3)) __wur;
5254
void free_pconfig(plugin_conf_t *config);
5355

5456
#endif

gcc-attributes.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,18 @@
4343
# define __attr_dealloc_free
4444
#endif
4545

46+
#ifndef __attribute_const__
47+
# define __attribute_const__
48+
#endif
49+
50+
#ifndef __attribute_pure__
51+
# define __attribute_pure__
52+
#endif
53+
54+
#ifndef __nonnull
55+
# define __nonnull(params)
56+
#endif
57+
4658
#ifndef __wur
4759
# define __wur
4860
#endif

src/auditd-config.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define AUDITD_CONFIG_H
2525

2626
#include "libaudit.h"
27+
#include "gcc-attributes.h"
2728
#include <grp.h>
2829
#define CONFIG_FILE "/etc/audit/auditd.conf"
2930
#define MEGABYTE 1048576UL
@@ -33,7 +34,8 @@
3334

3435
typedef enum { D_FOREGROUND, D_BACKGROUND } daemon_t;
3536
typedef enum { LF_RAW, LF_NOLOG, LF_ENRICHED } logging_formats;
36-
typedef enum { FT_NONE, FT_INCREMENTAL, FT_INCREMENTAL_ASYNC, FT_DATA, FT_SYNC } flush_technique;
37+
typedef enum { FT_NONE, FT_INCREMENTAL, FT_INCREMENTAL_ASYNC, FT_DATA,
38+
FT_SYNC } flush_technique;
3739
typedef enum { FA_IGNORE, FA_SYSLOG, FA_ROTATE, FA_EMAIL, FA_EXEC, FA_SUSPEND,
3840
FA_SINGLE, FA_HALT } failure_action_t;
3941
typedef enum { SZ_IGNORE, SZ_SYSLOG, SZ_EXEC, SZ_SUSPEND, SZ_ROTATE,
@@ -102,20 +104,21 @@ struct daemon_conf
102104
};
103105

104106
void set_allow_links(int allow);
105-
int set_config_dir(const char *val);
107+
int set_config_dir(const char *val) __nonnull ((1));
106108

107-
int load_config(struct daemon_conf *config, log_test_t lt);
108-
void clear_config(struct daemon_conf *config);
109-
const char *audit_lookup_format(int fmt);
110-
int create_log_file(const char *val);
111-
int resolve_node(struct daemon_conf *config);
112-
void setup_percentages(struct daemon_conf *config, int fd);
109+
int load_config(struct daemon_conf *config, log_test_t lt)
110+
__nonnull ((1)) __wur;
111+
void clear_config(struct daemon_conf *config) __nonnull ((1));
112+
const char *audit_lookup_format(int fmt) __attribute_const__;
113+
int create_log_file(const char *val) __nonnull ((1));
114+
int resolve_node(struct daemon_conf *config) __nonnull ((1));
115+
void setup_percentages(struct daemon_conf *config, int fd) __nonnull ((1));
113116

114117
void init_config_manager(void);
115118
#ifdef AUDITD_EVENT_H
116119
int start_config_manager(struct auditd_event *e);
117120
#endif
118-
void free_config(struct daemon_conf *config);
121+
void free_config(struct daemon_conf *config) __nonnull ((1));
119122

120123
const char *failure_action_to_str(unsigned int action);
121124

src/auditd-event.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include <stdio.h>
2828
#include "libaudit.h"
29+
#include "gcc-attributes.h"
2930

3031
typedef void (*ack_func_type)(void *ack_data, const unsigned char *header,
3132
const char *msg);
@@ -52,7 +53,7 @@ void cleanup_event(struct auditd_event *e);
5253
void format_event(struct auditd_event *e);
5354
void enqueue_event(struct auditd_event *e);
5455
void handle_event(struct auditd_event *e);
55-
void distribute_event(struct auditd_event *e);
56+
void distribute_event(struct auditd_event *e) __nonnull ((1));
5657
struct auditd_event *create_event(const char *msg, ack_func_type ack_func,
5758
void *ack_data, uint32_t sequence_id);
5859

0 commit comments

Comments
 (0)