Skip to content

Commit 9feea19

Browse files
committed
fix several LGTM warnings
1 parent 1c7a4e7 commit 9feea19

File tree

8 files changed

+21
-17
lines changed

8 files changed

+21
-17
lines changed

cmds.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
*
2020
*/
2121

22+
#ifndef _CORE_CMDS_H_
23+
#define _CORE_CMDS_H_
24+
2225
#include "parser/msg_parser.h"
2326
#include "route_struct.h"
2427
#include "async.h"
@@ -78,3 +81,5 @@ int check_acmd_call_params(acmd_export_t *acmd, action_elem_t *elems, int no_par
7881
cmd_export_t* find_core_cmd_export_t(char* name, int flags);
7982
cmd_export_t* find_mod_cmd_export_t(char* name, int flags);
8083
acmd_export_t* find_mod_acmd_export_t(char* name);
84+
85+
#endif /* _CORE_CMDS_H_ */

core_stats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static unsigned long get_pkg_fragments( void*proc_id)
184184

185185
int init_pkg_stats(int procs_no)
186186
{
187-
unsigned short n;
187+
int n;
188188
str n_str;
189189
char *name;
190190
str sname;

io_wait.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static inline int kq_ev_change(io_wait_h* h, int fd, int filter, int flag,
336336
* functions (it avoids functions calls, the overhead being only an extra
337337
* switch())
338338
*/
339-
inline static int io_watch_add( io_wait_h* h, /* lgtm [cpp/use-of-goto] */
339+
inline static int io_watch_add( io_wait_h* h, // lgtm [cpp/use-of-goto]
340340
int fd,
341341
fd_type type,
342342
void* data,

lib/csv.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ csv_record *__parse_csv_record(const str *_in, enum csv_flags parse_flags,
216216

217217
void free_csv_record(csv_record *record)
218218
{
219-
osips_free_t free_f;
220219
enum csv_flags flags_holder;
221220
struct str_list *prev;
222221

main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,8 @@ char* working_dir = 0;
261261
char* chroot_dir = 0;
262262
char* user=0;
263263
char* group=0;
264-
int uid = 0;
265-
int gid = 0;
264+
int user_id = 0;
265+
int group_id = 0;
266266

267267
/* more config stuff */
268268
int disable_core_dump=0; /* by default enabled */
@@ -273,7 +273,7 @@ int mcast_loopback = 0;
273273
int mcast_ttl = -1; /* if -1, don't touch it, use the default (usually 1) */
274274
#endif /* USE_MCAST */
275275

276-
int tos = IPTOS_LOWDELAY;
276+
int tos = IPTOS_LOWDELAY; // lgtm [cpp/short-global-name]
277277

278278
struct socket_info* bind_address=0; /* pointer to the crt. proc.
279279
listening address*/
@@ -984,13 +984,13 @@ int main(int argc, char** argv)
984984

985985
/* get uid/gid */
986986
if (user){
987-
if (user2uid(&uid, &gid, user)<0){
987+
if (user2uid(&user_id, &group_id, user)<0){
988988
LM_ERR("bad user name/uid number: -u %s\n", user);
989989
goto error00;
990990
}
991991
}
992992
if (group){
993-
if (group2gid(&gid, group)<0){
993+
if (group2gid(&group_id, group)<0){
994994
LM_ERR("bad group name/gid number: -u %s\n", group);
995995
goto error00;
996996
}
@@ -1477,7 +1477,7 @@ int main(int argc, char** argv)
14771477

14781478
/* all processes should have access to all the sockets (for sending)
14791479
* so we open all first*/
1480-
if (do_suid(uid, gid)==-1)
1480+
if (do_suid(user_id, group_id)==-1)
14811481
goto error;
14821482

14831483
ret = main_loop();

mem/hp_malloc_stats.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ void hp_init_shm_statistics(struct hp_block *hpb)
177177
shm_rused->flags |= STAT_NO_RESET;
178178
shm_frags->flags |= STAT_NO_RESET;
179179
#endif
180-
update_stat(shm_used, hpb->used);
181-
update_stat(shm_rused, hpb->real_used);
182-
update_stat(shm_frags, hpb->total_fragments);
180+
update_stat(shm_used, (int)hpb->used);
181+
update_stat(shm_rused, (int)hpb->real_used);
182+
update_stat(shm_frags, (int)hpb->total_fragments);
183183

184184
LM_DBG("initializing atomic shm statistics: "
185185
"[ us: %ld | rus: %ld | frags: %ld ]\n", hpb->used, hpb->real_used, hpb->total_fragments);

mi/mi_trace.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,8 @@ static int mi_mods_no=0;
206206

207207
static int is_id_valid(int id)
208208
{
209-
/* FIXME is this valid? */
210-
if ( id >= 8 * sizeof( *(((struct mi_cmd *)0)->trace_mask) ) ||
211-
id < 0 )
209+
/* mask is currehtly char, we might need to expand it to offer more space */
210+
if (id < 0 || id >= 8 * sizeof( *(((struct mi_cmd *)0)->trace_mask) ))
212211
return 0;
213212

214213
return 1;

pt_scaling.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ int create_auto_scaling_profile( char *name,
6868
down_cycles_tocheck = 0;
6969
down_cycles_delay = 0;
7070
}
71-
if (max_procs <= min_procs || max_procs==0 || max_procs>=1000) {
71+
if (max_procs==0 || max_procs <= min_procs || max_procs>=1000) {
7272
LM_ERR("invalid relation or range for MIN/MAX processes [%d,%d]\n",
7373
min_procs, max_procs);
7474
return -1;
7575
}
76-
if (up_threshold <= down_threshold || up_threshold==0 ||
76+
if (up_threshold==0 || up_threshold <= down_threshold ||
7777
up_threshold>100 || down_threshold>100) {
7878
LM_ERR("invalid relation or range DOWN/UP thresholds percentages "
7979
"[%d,%d]\n", down_threshold, up_threshold);
@@ -361,6 +361,7 @@ void do_workers_auto_scaling(void)
361361
do {
362362
load += pg->history_map[k];
363363
k = k ? (k-1) : (pg->history_size-1) ;
364+
i++;
364365
} while( k != idx && i <= pg->prof->down_cycles_tocheck );
365366
load = (load*procs_no) /
366367
(pg->prof->down_cycles_tocheck * (procs_no-1));

0 commit comments

Comments
 (0)