Skip to content

Commit

Permalink
gcc 5.1 warnings fix
Browse files Browse the repository at this point in the history
re-arranged code to comply with gnu11

(cherry picked from commit 9da7c53)
  • Loading branch information
razvancrainea committed Aug 21, 2015
1 parent efda8e1 commit 239c4a0
Show file tree
Hide file tree
Showing 50 changed files with 181 additions and 182 deletions.
18 changes: 9 additions & 9 deletions context.c
Expand Up @@ -47,7 +47,7 @@ context_p context_alloc(void)
return ctx;
}

inline int context_register_int(enum osips_context type)
int context_register_int(enum osips_context type)
{
context_sizes[type] += sizeof(int);
type_offsets[type][1] += sizeof(int);
Expand All @@ -56,22 +56,22 @@ inline int context_register_int(enum osips_context type)
return type_sizes[type][0]++;
}

inline int context_register_str(enum osips_context type)
int context_register_str(enum osips_context type)
{
context_sizes[type] += sizeof(str);
type_offsets[type][2] += sizeof(str);

return type_sizes[type][1]++;
}

inline int context_register_ptr(enum osips_context type)
int context_register_ptr(enum osips_context type)
{
context_sizes[type] += sizeof(void *);

return type_sizes[type][2]++;
}

inline void context_put_int(enum osips_context type, context_p ctx,
void context_put_int(enum osips_context type, context_p ctx,
int pos, int data)
{
#ifdef DBG_QM_MALLOC
Expand All @@ -87,7 +87,7 @@ inline void context_put_int(enum osips_context type, context_p ctx,
((int *)ctx)[pos] = data;
}

inline void context_put_str(enum osips_context type, context_p ctx,
void context_put_str(enum osips_context type, context_p ctx,
int pos, str *data)
{
#ifdef DBG_QM_MALLOC
Expand All @@ -103,7 +103,7 @@ inline void context_put_str(enum osips_context type, context_p ctx,
((str *)((char *)ctx + type_offsets[type][1]))[pos] = *data;
}

inline void context_put_ptr(enum osips_context type, context_p ctx,
void context_put_ptr(enum osips_context type, context_p ctx,
int pos, void *data)
{
#ifdef DBG_QM_MALLOC
Expand All @@ -119,7 +119,7 @@ inline void context_put_ptr(enum osips_context type, context_p ctx,
((void **)((char *)ctx + type_offsets[type][2]))[pos] = data;
}

inline int context_get_int(enum osips_context type, context_p ctx, int pos)
int context_get_int(enum osips_context type, context_p ctx, int pos)
{
#ifdef DBG_QM_MALLOC
if (pos < 0 || pos >= type_sizes[type][0]) {
Expand All @@ -134,7 +134,7 @@ inline int context_get_int(enum osips_context type, context_p ctx, int pos)
return ((int *)ctx)[pos];
}

inline str *context_get_str(enum osips_context type, context_p ctx, int pos)
str *context_get_str(enum osips_context type, context_p ctx, int pos)
{
#ifdef DBG_QM_MALLOC
if (pos < 0 || pos >= type_sizes[type][1]) {
Expand All @@ -149,7 +149,7 @@ inline str *context_get_str(enum osips_context type, context_p ctx, int pos)
return &((str *)((char *)ctx + type_offsets[type][1]))[pos];
}

inline void *context_get_ptr(enum osips_context type, context_p ctx, int pos)
void *context_get_ptr(enum osips_context type, context_p ctx, int pos)
{
#ifdef DBG_QM_MALLOC
if (pos < 0 || pos >= type_sizes[type][2]) {
Expand Down
18 changes: 9 additions & 9 deletions context.h
Expand Up @@ -67,19 +67,19 @@ context_p context_alloc(void);
*
* - they reserve and return a position in the context buffer of the given type
*/
extern inline int context_register_int(enum osips_context type);
extern inline int context_register_str(enum osips_context type);
extern inline int context_register_ptr(enum osips_context type);
int context_register_int(enum osips_context type);
int context_register_str(enum osips_context type);
int context_register_ptr(enum osips_context type);

extern inline void context_put_int(enum osips_context type, context_p ctx,
void context_put_int(enum osips_context type, context_p ctx,
int pos, int data);
extern inline void context_put_str(enum osips_context type, context_p ctx,
void context_put_str(enum osips_context type, context_p ctx,
int pos, str *data);
extern inline void context_put_ptr(enum osips_context type, context_p ctx,
void context_put_ptr(enum osips_context type, context_p ctx,
int pos, void *data);

extern inline int context_get_int(enum osips_context type, context_p ctx, int pos);
extern inline str *context_get_str(enum osips_context type, context_p ctx, int pos);
extern inline void *context_get_ptr(enum osips_context type, context_p ctx, int pos);
int context_get_int(enum osips_context type, context_p ctx, int pos);
str *context_get_str(enum osips_context type, context_p ctx, int pos);
void *context_get_ptr(enum osips_context type, context_p ctx, int pos);

#endif /* __CONTEXT_H */
4 changes: 2 additions & 2 deletions core_stats.c
Expand Up @@ -36,6 +36,7 @@
#include "statistics.h"
#include "globals.h"
#include "pt.h"
#include "timer.h"
#include <sys/types.h>
#include <signal.h>
#include "socket_info.h"
Expand Down Expand Up @@ -69,8 +70,7 @@ stat_export_t core_stats[] = {
{"bad_URIs_rcvd", 0, &bad_URIs },
{"unsupported_methods", 0, &unsupported_methods },
{"bad_msg_hdr", 0, &bad_msg_hdr },
{"timestamp", STAT_IS_FUNC, (stat_var**)get_ticks },
{0,0,0}
{"timestamp", STAT_IS_FUNC, (stat_var**)get_ticks }, {0,0,0}
};


Expand Down
4 changes: 3 additions & 1 deletion daemonize.c
Expand Up @@ -54,7 +54,9 @@
#include <sys/prctl.h>
#endif

#include "mem/shm_mem.h"
#include "daemonize.h"
#include "sr_module.h"
#include "globals.h"
#include "dprint.h"
#include "pt.h"
Expand Down Expand Up @@ -95,7 +97,7 @@ int create_status_pipe(void)
return rc;
}

inline void inc_init_timer(void)
void inc_init_timer(void)
{
LM_DBG("incrementing init timer no\n");
(*init_timer_no)++;
Expand Down
2 changes: 1 addition & 1 deletion daemonize.h
Expand Up @@ -36,7 +36,7 @@ int send_status_code(char val);
void clean_write_pipeend(void);
int create_status_pipe(void);
int wait_for_all_children(void);
extern inline void inc_init_timer(void);
void inc_init_timer(void);


#define report_failure_status() \
Expand Down
6 changes: 3 additions & 3 deletions db/db_insertq.c
Expand Up @@ -468,7 +468,7 @@ query_list_t *find_query_list_unsafe(const str *table,db_key_t *cols,int col_no)
*
* also takes care of initialisation of this is the first process
* attempting to execute this type of query */
inline int con_set_inslist(db_func_t *dbf,db_con_t *con,query_list_t **list,
int con_set_inslist(db_func_t *dbf,db_con_t *con,query_list_t **list,
db_key_t *cols,int col_no)
{
query_list_t *entry;
Expand Down Expand Up @@ -534,7 +534,7 @@ inline int con_set_inslist(db_func_t *dbf,db_con_t *con,query_list_t **list,
}

/* clean shm memory used by the rows */
inline void cleanup_rows(db_val_t **rows)
void cleanup_rows(db_val_t **rows)
{
int i;

Expand Down Expand Up @@ -606,7 +606,7 @@ void ql_timer_routine(unsigned int ticks,void *param)
}
}

inline int ql_flush_rows(db_func_t *dbf,db_con_t *conn,query_list_t *entry)
int ql_flush_rows(db_func_t *dbf,db_con_t *conn,query_list_t *entry)
{
if (query_buffer_size <= 1 || !entry)
return 0;
Expand Down
7 changes: 3 additions & 4 deletions db/db_insertq.h
Expand Up @@ -63,11 +63,10 @@ extern gen_lock_t *ql_lock;
int init_ql_support(void);
int ql_row_add(query_list_t *entry,const db_val_t *row,db_val_t ***ins_rows);
int ql_detach_rows_unsafe(query_list_t *entry,db_val_t ***ins_rows);
extern inline int con_set_inslist(db_func_t *dbf,db_con_t *con,
int con_set_inslist(db_func_t *dbf,db_con_t *con,
query_list_t **list,db_key_t *cols,int col_no);
void ql_timer_routine(unsigned int ticks,void *param);
extern inline int ql_flush_rows(db_func_t *dbf,
db_con_t *conn,query_list_t *entry);
int ql_flush_rows(db_func_t *dbf, db_con_t *conn,query_list_t *entry);

#define CON_RESET_INSLIST(con) \
do { \
Expand All @@ -93,7 +92,7 @@ extern inline int ql_flush_rows(db_func_t *dbf,
lock_release((entry)->lock); \
} while (0)

extern inline void cleanup_rows(db_val_t **rows);
void cleanup_rows(db_val_t **rows);
void handle_ql_shutdown(void);

#endif
29 changes: 1 addition & 28 deletions dprint.c
Expand Up @@ -112,35 +112,8 @@ void cleanup_debug(void)
debug = &debug_level;
}

/* change the default log level of a given process */
inline void __set_proc_default_debug(int proc_idx, int level)
{
pt[proc_idx].default_debug = level;
}

/* change the actual log level of the current process */
inline void set_proc_debug_level(int level)
{
__set_proc_debug_level(process_no, level);
}

/* change the actual log level of a given process */
inline void __set_proc_debug_level(int proc_idx, int level)
{
pt[proc_idx].debug = level;
}

inline void set_global_debug_level(int level)
{
int i;

for (i = 0; i < counted_processes; i++) {
__set_proc_default_debug(i, level);
__set_proc_debug_level(i, level);
}
}

inline void reset_proc_debug_level(void)
void reset_proc_debug_level(void)
{
*debug = *default_debug;
}
41 changes: 31 additions & 10 deletions dprint.h
Expand Up @@ -52,6 +52,8 @@
#include <syslog.h>
#include <time.h>

#include "pt.h"

#define L_ALERT -3 /*!< Alert level */
#define L_CRIT -2 /*!< Critical level */
#define L_ERR -1 /*!< Error level */
Expand Down Expand Up @@ -116,24 +118,43 @@ void dprint (char* format, ...);

int str2facility(char *s);

/* set the current and default log levels for all OpenSIPS processes */
extern inline void set_global_debug_level(int level);

/* set the log level of the current process */
extern inline void set_proc_debug_level(int level);

/*
* set the (default) log level of a given process
*
* Note: the index param is not validated!
*/
extern inline void __set_proc_debug_level(int proc_idx, int level);
extern inline void __set_proc_default_debug(int proc_idx, int level);
static inline void __set_proc_debug_level(int proc_idx, int level)
{
pt[proc_idx].debug = level;
}

static inline void __set_proc_default_debug(int proc_idx, int level)
{
pt[proc_idx].default_debug = level;
}

/* set the current and default log levels for all OpenSIPS processes */
static inline void set_global_debug_level(int level)
{
int i;

for (i = 0; i < counted_processes; i++) {
__set_proc_default_debug(i, level);
__set_proc_debug_level(i, level);
}
}

/* set the log level of the current process */
static inline void set_proc_debug_level(int level)
{
__set_proc_debug_level(process_no, level);
}


/* changes the logging level to the default value for the current process */
extern inline void reset_proc_debug_level(void);
void reset_proc_debug_level(void);

inline static char* dp_time(void)
static inline char* dp_time(void)
{
time_t ltime;

Expand Down
1 change: 1 addition & 0 deletions forward.c
Expand Up @@ -71,6 +71,7 @@
#include "sr_module.h"
#include "ip_addr.h"
#include "resolve.h"
#include "net/trans.h"
#include "name_alias.h"
#include "socket_info.h"
#include "core_stats.h"
Expand Down
1 change: 1 addition & 0 deletions io_wait.h
Expand Up @@ -89,6 +89,7 @@

#include "poll_types.h" /* poll_types*/
#include "pt.h" /* mypid() */
#include "error.h"

#ifndef FD_TYPE_DEFINED
typedef int fd_type;
Expand Down
2 changes: 1 addition & 1 deletion mem/mem.c
Expand Up @@ -166,7 +166,7 @@ void pkg_event_raise(long used, long size, long perc)
event_pkg_pending = 0;
}

inline void pkg_threshold_check(void)
void pkg_threshold_check(void)
{
long pkg_perc, used, size;

Expand Down
2 changes: 1 addition & 1 deletion mem/meminfo.h
Expand Up @@ -44,7 +44,7 @@ struct mem_info{
// threshold percentage checked
extern long event_pkg_threshold;
// events are used only if STATISTICS are used
extern inline void pkg_threshold_check(void);
void pkg_threshold_check(void);
#else
#define pkg_threshold_check()
#endif /* STATISTICS */
Expand Down
4 changes: 2 additions & 2 deletions modules/alias_db/alookup.c
Expand Up @@ -217,7 +217,7 @@ static int alias_db_query(struct sip_msg* _msg, char* _table,
}


inline int set_alias_to_ruri(struct sip_msg* _msg, str *alias, int no, void *p)
static inline int set_alias_to_ruri(struct sip_msg* _msg, str *alias, int no, void *p)
{
/* set the RURI */
if(no==0) {
Expand Down Expand Up @@ -248,7 +248,7 @@ int alias_db_lookup(struct sip_msg* _msg, char* _table, char *flags)
}


inline int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, void *p)
static inline int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, void *p)
{
pv_value_t val;
pv_spec_t *pvs=(pv_spec_t*)p;
Expand Down
4 changes: 2 additions & 2 deletions modules/benchmark/benchmark.h
Expand Up @@ -60,7 +60,7 @@ typedef struct benchmark_timer
struct benchmark_timer *next;
} benchmark_timer_t;

extern inline int bm_get_time(bm_timeval_t *t)
static inline int bm_get_time(bm_timeval_t *t)
{
#ifdef BM_CLOCK_REALTIME
if(clock_gettime(CLOCK_REALTIME, t)!=0)
Expand All @@ -75,7 +75,7 @@ extern inline int bm_get_time(bm_timeval_t *t)
return 0;
}

extern inline unsigned long long bm_diff_time(bm_timeval_t *t1, bm_timeval_t *t2)
static inline unsigned long long bm_diff_time(bm_timeval_t *t1, bm_timeval_t *t2)
{
unsigned long long tdiff;

Expand Down
4 changes: 2 additions & 2 deletions modules/dialog/dlg_hash.c
Expand Up @@ -215,7 +215,7 @@ static inline void free_dlg_dlg(struct dlg_cell *dlg)
}


inline void destroy_dlg(struct dlg_cell *dlg)
void destroy_dlg(struct dlg_cell *dlg)
{
int ret = 0;

Expand Down Expand Up @@ -721,7 +721,7 @@ void link_dlg(struct dlg_cell *dlg, int n)



inline void unlink_unsafe_dlg(struct dlg_entry *d_entry,
void unlink_unsafe_dlg(struct dlg_entry *d_entry,
struct dlg_cell *dlg)
{
if (dlg->next)
Expand Down

0 comments on commit 239c4a0

Please sign in to comment.