Skip to content

Commit 7de6cb4

Browse files
committed
Compiler warning fixes
1 parent 567d1bb commit 7de6cb4

File tree

13 files changed

+15
-15
lines changed

13 files changed

+15
-15
lines changed

apps/mosquitto_ctrl/ctrl_shell.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
2121
#include <arpa/inet.h>
2222
#include <ctype.h>
2323
#include <errno.h>
24-
#include <editline/readline.h>
2524
#include <fcntl.h>
2625
#include <pthread.h>
2726
#include <signal.h>
@@ -131,7 +130,7 @@ static void term_set_canon(bool canon)
131130
void ctrl_shell_rtrim(char *buf)
132131
{
133132
size_t slen = strlen(buf);
134-
while(slen > 0 && isspace(buf[slen-1])){
133+
while(slen > 0 && isspace((unsigned char)buf[slen-1])){
135134
buf[slen-1] = '\0';
136135
slen = strlen(buf);
137136
}

apps/mosquitto_ctrl/ctrl_shell.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern "C" {
2424

2525
#include <cjson/cJSON.h>
2626
#include <stdbool.h>
27+
#include <stdio.h>
2728

2829
extern const char *ANSI_URL;
2930
extern const char *ANSI_MODULE;

apps/mosquitto_ctrl/ctrl_shell_dynsec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ static void print_details(cJSON *j_data)
795795
int64_t groupcount;
796796
int64_t rolecount;
797797
int64_t changeindex;
798-
int align = strlen("Change index: ");
798+
int align = (int)strlen("Change index: ");
799799
json_get_int64(j_data, "clientCount", &clientcount, true, 0);
800800
json_get_int64(j_data, "groupCount", &groupcount, true, 0);
801801
json_get_int64(j_data, "roleCount", &rolecount, true, 0);

apps/mosquitto_ctrl/dynsec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static void print_json_array(cJSON *j_list, int slen, const char *label, const c
184184
static void print_client(cJSON *j_response)
185185
{
186186
cJSON *j_data, *j_client, *jtmp;
187-
const int label_width = strlen("Connections:");
187+
const int label_width = (int)strlen("Connections:");
188188

189189
j_data = cJSON_GetObjectItem(j_response, "data");
190190
if(j_data == NULL || !cJSON_IsObject(j_data)){
@@ -226,7 +226,7 @@ static void print_client(cJSON *j_response)
226226
static void print_group(cJSON *j_response)
227227
{
228228
cJSON *j_data, *j_group;
229-
int label_width = strlen("Groupname:");
229+
int label_width = (int)strlen("Groupname:");
230230
const char *groupname;
231231

232232
j_data = cJSON_GetObjectItem(j_response, "data");

apps/mosquitto_passwd/mosquitto_passwd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static bool is_username_valid(const char *username)
413413
return false;
414414
}
415415
for(i=0; i<slen; i++){
416-
if(iscntrl(username[i])){
416+
if(iscntrl((unsigned char)username[i])){
417417
fprintf(stderr, "Error: Username must not contain control characters.\n");
418418
return false;
419419
}

lib/packet_mosq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
4848

4949
int packet__alloc(struct mosquitto__packet **packet, uint8_t command, uint32_t remaining_length)
5050
{
51-
uint8_t remaining_bytes[5], byte;
51+
uint8_t remaining_bytes[5] = {0}, byte;
5252
int8_t remaining_count;
5353
uint32_t packet_length;
5454
uint32_t remaining_length_stored;

libcommon/file_common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ char *mosquitto_trimblanks(char *str)
262262
return NULL;
263263
}
264264

265-
while(isspace(str[0])){
265+
while(isspace((unsigned char)str[0])){
266266
str++;
267267
}
268268
endptr = &str[strlen(str)-1];
269-
while(endptr > str && isspace(endptr[0])){
269+
while(endptr > str && isspace((unsigned char)endptr[0])){
270270
endptr[0] = '\0';
271271
endptr--;
272272
}

plugins/acl-file/acl_parse.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ int acl_file__parse(struct acl_file_data *data)
213213

214214
while(mosquitto_fgets(&buf, &buflen, aclfptr)){
215215
slen = strlen(buf);
216-
while(slen > 0 && isspace(buf[slen-1])){
216+
while(slen > 0 && isspace((unsigned char)buf[slen-1])){
217217
buf[slen-1] = '\0';
218218
slen = strlen(buf);
219219
}

plugins/dynamic-security/config_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ static int get_password_from_init_file(struct dynsec__data *data, char **pw)
8282
fclose(fptr);
8383

8484
pos = (int)strlen(buf)-1;
85-
while(pos >= 0 && isspace(buf[pos])){
85+
while(pos >= 0 && isspace((unsigned char)buf[pos])){
8686
buf[pos] = '\0';
8787
pos--;
8888
}

src/conf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3003,7 +3003,7 @@ static int config__check(struct mosquitto__config *config)
30033003
id_prefix_len = config->security_options.auto_id_prefix_len;
30043004
}else{
30053005
id_prefix = "auto-";
3006-
id_prefix_len = strlen("auto-");
3006+
id_prefix_len = (int)strlen("auto-");
30073007
}
30083008

30093009
/* Default to auto_id_prefix = 'auto-' if none set. */

0 commit comments

Comments
 (0)