Skip to content

Commit 6baa3aa

Browse files
committedFeb 4, 2019
fix a couple of lgtm issues
1 parent 02a608c commit 6baa3aa

13 files changed

+37
-31
lines changed
 

‎bin_interface.c

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
static int bin_extend(bin_packet_t *packet, int size);
3232

33-
struct socket_info *bin;
34-
3533
static struct packet_cb_list *reg_cbs;
3634

3735

‎error.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int ser_error=-1;
4545
int prev_ser_error=-1;
4646

4747
int err2reason_phrase(
48-
int ser_error, /*!< current internal ser error */
48+
int error, /*!< current internal ser error */
4949
int *sip_error, /*!< the sip error code to which ser error will be turned */
5050
char *phrase, /*!< resulting error text */
5151
int etl, /*!< error text buffer length */
@@ -54,26 +54,26 @@ int err2reason_phrase(
5454

5555
char *error_txt;
5656

57-
switch( ser_error ) {
57+
switch( error ) {
5858
case E_IP_BLOCKED:
5959
error_txt="Filtered destination";
60-
*sip_error=-ser_error;
60+
*sip_error=-error;
6161
break;
6262
case E_SEND:
6363
error_txt="Send failed";
64-
*sip_error=-ser_error;
64+
*sip_error=-error;
6565
break;
6666
case E_BAD_ADDRESS:
6767
error_txt="Unresolvable destination";
68-
*sip_error=-ser_error;
68+
*sip_error=-error;
6969
break;
7070
case E_BAD_REQ:
7171
error_txt="Bad Request";
72-
*sip_error=-ser_error;
72+
*sip_error=-error;
7373
break;
7474
case E_BAD_URI:
7575
error_txt="Bad URI";
76-
*sip_error=-ser_error;
76+
*sip_error=-error;
7777
break;
7878
case E_BAD_TUPEL:
7979
error_txt="Transaction tuple incomplete";
@@ -120,7 +120,7 @@ int err2reason_phrase(
120120
break;
121121
}
122122
return snprintf( phrase, etl, "%s (%d/%s)", error_txt,
123-
-ser_error, signature );
123+
-error, signature );
124124
}
125125

126126
char *error_text( int code )

‎io_wait.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static inline int kq_ev_change(io_wait_h* h, int fd, int filter, int flag,
334334
* functions (it avoids functions calls, the overhead being only an extra
335335
* switch())
336336
*/
337-
inline static int io_watch_add( io_wait_h* h,
337+
inline static int io_watch_add( io_wait_h* h, /* lgtm [cpp/use-of-goto] */
338338
int fd,
339339
fd_type type,
340340
void* data,

‎mem/module_info.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void* main_handle = NULL;
4141
volatile struct module_info* memory_mods_stats = NULL;
4242
int core_index;
4343

44-
int set_mem_idx(char* mod_name, int mem_free_idx) {
44+
int set_mem_idx(char* mod_name, int new_mem_free_idx) {
4545

4646
int *var;
4747
if(!main_handle){
@@ -53,7 +53,7 @@ int set_mem_idx(char* mod_name, int mem_free_idx) {
5353
}
5454

5555
if(strlen(mod_name) == 4 && (strncmp("core", mod_name, 4) == 0))
56-
core_index = mem_free_idx;
56+
core_index = new_mem_free_idx;
5757

5858
strcpy(buff, mod_name);
5959
strcat(buff, STAT_SUFIX);
@@ -66,7 +66,7 @@ int set_mem_idx(char* mod_name, int mem_free_idx) {
6666
return -1;
6767
}
6868

69-
*var = mem_free_idx;
69+
*var = new_mem_free_idx;
7070
LM_DBG("changed module variable %s = %d\n", buff, *var);
7171

7272
return 0;

‎mem/q_malloc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
#if !defined(q_malloc_h) && !defined(VQ_MALLOC) && !defined(F_MALLOC) && \
33-
!defined(HP_MALLOC)
33+
!defined(HP_MALLOC) /* lgtm [cpp/missing-header-guard] */
3434
#define q_malloc_h
3535

3636
#include "meminfo.h"

‎mi/mi_trace.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ char* generate_correlation_id(int* len)
128128

129129

130130
int trace_mi_message(union sockaddr_union* src, union sockaddr_union* dst,
131-
struct mi_trace_param* pld_param, str* correlation_value, trace_dest trace_dst)
131+
struct mi_trace_param* pld_param, str* correlation_val, trace_dest trace_dst)
132132
{
133133
/* FIXME is this the case for all mi impelementations?? */
134134
const int proto = IPPROTO_TCP;
@@ -149,16 +149,16 @@ int trace_mi_message(union sockaddr_union* src, union sockaddr_union* dst,
149149
return -1;
150150
}
151151

152-
if ( correlation_value ) {
152+
if ( correlation_val ) {
153153
if ( correlation_id < 0 || correlation_vendor < 0 ) {
154154
if ( load_correlation_id() < 0 ) {
155155
LM_ERR("can't load correlation id!\n");
156156
goto error;
157157
}
158158
}
159159

160-
if ( mi_trace_api->add_chunk( message, correlation_value->s,
161-
correlation_value->len, TRACE_TYPE_STR,
160+
if ( mi_trace_api->add_chunk( message, correlation_val->s,
161+
correlation_val->len, TRACE_TYPE_STR,
162162
correlation_id, correlation_vendor) < 0 ) {
163163
LM_ERR("can't set the correlation id!\n");
164164
goto error;

‎modules/call_center/call_center.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ static int w_agent_login(struct sip_msg *req, char *agent_v, char *state_v)
911911

912912
/* get state */
913913
if (fixup_get_isvalue( req, (gparam_p)state_v, &state, &agent_s,
914-
&flags)!=0 || ((flags|GPARAM_INT_VALUE_FLAG)==0) ) {
914+
&flags)!=0 || ((flags&GPARAM_INT_VALUE_FLAG)==0) ) {
915915
LM_ERR("unable to evaluate state spec \n");
916916
return -1;
917917
}

‎modules/imc/imc_cmd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ int imc_handle_list(struct sip_msg* msg, imc_cmd_t *cmd,
794794
goto error;
795795
}
796796
p = imc_body_buf;
797-
strncpy(p, "Members:\n", 9);
797+
memcpy(p, "Members:\n", 9);
798798
p+=9;
799799
imp = room->members;
800800

‎modules/msilo/msfuncs.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ int m_build_headers(str *buf, str ctype, str contact, time_t date)
212212
p += 14;
213213
memcpy(p, ctype.s, ctype.len);
214214
p += ctype.len;
215-
strncpy(p, CRLF, CRLF_LEN);
215+
memcpy(p, CRLF, CRLF_LEN);
216216
p += CRLF_LEN;
217217

218218
}
@@ -251,18 +251,18 @@ int m_build_body(str *body, time_t date, str msg, time_t sdate)
251251
{
252252
if(sdate!=0)
253253
{
254-
strncpy(p, "[Reminder message - ", 20);
254+
memcpy(p, "[Reminder message - ", 20);
255255
p += 20;
256256

257-
strncpy(p, ctime(&sdate), 24);
257+
memcpy(p, ctime(&sdate), 24);
258258
p += 24;
259259

260260
*p++ = ']';
261261
} else {
262-
strncpy(p, "[Offline message - ", 19);
262+
memcpy(p, "[Offline message - ", 19);
263263
p += 19;
264264

265-
strncpy(p, ctime(&date), 24);
265+
memcpy(p, ctime(&date), 24);
266266
p += 24;
267267

268268
*p++ = ']';

‎name_alias.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
* the aliases (bogdan)
2727
*/
2828

29+
#ifndef NAME_ALIAS_H
30+
#define NAME_ALIAS_H
31+
2932

3033
#include <strings.h>
3134
#include "str.h"
@@ -88,4 +91,4 @@ int add_alias(char* name, int len, unsigned short port, unsigned short proto);
8891
/* register a new function for detecting aliases */
8992
int register_alias_fct( is_alias_fct *fct );
9093

91-
94+
#endif /* NAME_ALIAS_H */

‎net/proto_tcp/proto_tcp.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ static int tcp_read_req(struct tcp_connection* con, int* bytes_read)
12011201
return -1;
12021202
}
12031203

1204-
static mi_response_t *w_tcp_trace_mi(const mi_params_t *params,
1204+
static mi_response_t *w_tcp_trace_mi(const mi_params_t *mi_params,
12051205
struct mi_handler *async_hdl)
12061206
{
12071207
mi_response_t *resp;
@@ -1220,12 +1220,12 @@ static mi_response_t *w_tcp_trace_mi(const mi_params_t *params,
12201220
return resp;
12211221
}
12221222

1223-
static mi_response_t *w_tcp_trace_mi_1(const mi_params_t *params,
1223+
static mi_response_t *w_tcp_trace_mi_1(const mi_params_t *mi_params,
12241224
struct mi_handler *async_hdl)
12251225
{
12261226
str new_mode;
12271227

1228-
if (get_mi_string_param(params, "trace_mode", &new_mode.s, &new_mode.len) < 0)
1228+
if (get_mi_string_param(mi_params, "trace_mode", &new_mode.s, &new_mode.len) < 0)
12291229
return init_mi_param_error();
12301230

12311231
if ((new_mode.s[0] | 0x20) == 'o' &&

‎resolve.c

+4
Original file line numberDiff line numberDiff line change
@@ -941,8 +941,12 @@ struct txt_rdata* dns_txt_parser( unsigned char* msg, unsigned char* end,
941941
len = *rdata;
942942
if (rdata + 1 + len >= end)
943943
goto error; /* something fishy in the record */
944+
945+
#if 0
946+
/* Comparison is always false because len <= 255. */
944947
if (len >= sizeof(txt->txt))
945948
goto error; /* not enough space? */
949+
#endif
946950
memcpy(txt->txt, rdata+1, len);
947951
txt->txt[len] = 0; /* 0-terminate string */
948952
return txt;

‎socket_info.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,8 @@ int get_socket_list_from_proto(unsigned int **ipList, int protocol) {
873873
return 0;
874874
}
875875

876-
*ipList = pkg_malloc(numberOfSockets * (num_ip_octets + 1) * sizeof(int));
876+
*ipList = pkg_malloc(numberOfSockets *
877+
(num_ip_octets + 1) * (int)sizeof(int));
877878

878879
/* We couldn't allocate memory for the IP List. So all we can do is
879880
* fail. */

0 commit comments

Comments
 (0)
Please sign in to comment.