Skip to content

Commit 82f95f8

Browse files
author
Yorhel
committed
Various fixes and improvements found by LLVM's scan-build
As reported by http://dev.yorhel.nl/ncdc/bug/64
1 parent e5c8118 commit 82f95f8

File tree

6 files changed

+10
-13
lines changed

6 files changed

+10
-13
lines changed

src/cc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -847,7 +847,7 @@ static void adc_handle(net_t *net, char *msg, int _len) {
847847
}
848848

849849
if(cmd.type != 'C') {
850-
g_message("CC:%s: Not a client command: %s. --> %s", net_remoteaddr(cc->net), err->message, msg);
850+
g_message("CC:%s: Not a client command: %s", net_remoteaddr(cc->net), msg);
851851
g_strfreev(cmd.argv);
852852
return;
853853
}

src/commands.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static cmd_t *getcmd(const char *name) {
5656
// Get documentation for a command. May be slow at first, but caches the doc
5757
// structure later on.
5858
static doc_cmd_t *getdoc(cmd_t *cmd) {
59-
doc_cmd_t empty = { "", NULL, "No documentation available." };
59+
static doc_cmd_t empty = { "", NULL, "No documentation available." };
6060
if(cmd->doc)
6161
return cmd->doc;
6262
doc_cmd_t *i = (doc_cmd_t *)doc_cmds;
@@ -416,7 +416,6 @@ static void c_open(char *args) {
416416
return;
417417
}
418418

419-
ui_tab_t *tab = ui_tab_cur->data;
420419
gboolean conn = TRUE;
421420
if(strncmp(args, "-n ", 3) == 0) {
422421
conn = FALSE;
@@ -444,16 +443,13 @@ static void c_open(char *args) {
444443
}
445444
// Open or select tab
446445
if(!n) {
447-
tab = uit_hub_create(name, addr ? FALSE : conn);
446+
ui_tab_t *tab = uit_hub_create(name, addr ? FALSE : conn);
448447
ui_tab_open(tab, TRUE, NULL);
449448
listen_refresh();
450-
} else if(n != ui_tab_cur) {
449+
} else if(n != ui_tab_cur)
451450
ui_tab_cur = n;
452-
tab = n->data;
453-
} else {
451+
else
454452
ui_m(NULL, 0, addr ? "Tab already selected, saving new address instead." : "Tab already selected.");
455-
tab = n->data;
456-
}
457453
// Save address and (re)connect when necessary
458454
if(addr && c_connect_set_hubaddr(addr) && conn)
459455
c_reconnect("");

src/fl_util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ fl_list_t *fl_list_from_path(fl_list_t *root, const char *path) {
280280
void fl_list_suggest(fl_list_t *root, char *opath, char **sug) {
281281
fl_list_t *parent = root;
282282
char *path = g_strdup(opath);
283-
char *name = path;
283+
char *name;
284284
char *sep = strrchr(path, '/');
285285
if(sep) {
286286
*sep = 0;

src/net.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,8 @@ void net_disconnect(net_t *n) {
13071307
case NETST_ASY:
13081308
case NETST_DIS:
13091309
n->rd_cb = NULL;
1310-
if(n->syn) {
1310+
s = n->syn;
1311+
if(s) {
13111312
syn_cancel(n);
13121313
syn_free(s);
13131314
}

src/search.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ gboolean search_handle_udp(const char *addr, char *pack, int len) {
537537
}
538538

539539
// handle message
540-
char *next = msg;
540+
char *next;
541541
while((next = strchr(msg, adc ? '\n' : '|')) != NULL) {
542542
*(next++) = 0;
543543
g_debug("%s:%s< %s", sudp ? "SUDP" : "UDP", addr, msg);

src/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ gboolean file_move(const char *from, const char *to, gboolean overwrite, GError
467467
if(r <= 0)
468468
break;
469469

470+
char *p = buf;
470471
while(r > 0) {
471-
char *p = buf;
472472
int w = write(tofd, p, r);
473473
if(w < 0 && errno == EINTR)
474474
continue;

0 commit comments

Comments
 (0)