scan-build: fix a couple of minor warnings from a scan-build run

This commit is contained in:
Daniel Eklöf 2019-11-05 10:39:36 +01:00
parent 9abc5ca971
commit 15b12f45c6
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 7 additions and 5 deletions

4
csi.c
View file

@ -54,8 +54,8 @@ csi_as_string(struct terminal *term, uint8_t final)
i == term->vt.params.idx - 1 ? "" : ";");
}
c += snprintf(&msg[c], sizeof(msg) - c, "%c (%zu parameters)",
final, term->vt.params.idx);
snprintf(&msg[c], sizeof(msg) - c, "%c (%zu parameters)",
final, term->vt.params.idx);
return msg;
}

2
log.c
View file

@ -100,7 +100,7 @@ _sys_log(enum log_class log_class, const char *module,
idx += vsnprintf(&msg[idx], required_len + 1 - idx, fmt, va);
if (sys_errno != 0) {
idx += snprintf(
snprintf(
&msg[idx], required_len + 1 - idx, ": %s", strerror(sys_errno));
}

1
main.c
View file

@ -143,6 +143,7 @@ main(int argc, char *const *argv)
unsigned width, height;
if (sscanf(optarg, "%ux%u", &width, &height) != 2 || width == 0 || height == 0) {
fprintf(stderr, "error: invalid geometry: %s\n", optarg);
config_free(conf);
return EXIT_FAILURE;
}

View file

@ -108,6 +108,7 @@ extract_selection(const struct terminal *term)
start_col = 0;
}
assert(idx > 0);
assert(idx < buf_size);
if (buf[idx - 1] == '\n')
buf[idx - 1] = '\0';

2
shm.c
View file

@ -148,7 +148,7 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie)
/* We use the entire pool for our single buffer */
wl_shm_pool_destroy(pool); pool = NULL;
close(pool_fd); pool_fd = -1;
close(pool_fd);
/* One pixman image for each worker thread (do we really need multiple?) */
pix = pixman_image_create_bits_no_clear(

2
vt.c
View file

@ -581,7 +581,7 @@ esc_as_string(struct terminal *term, uint8_t final)
assert(term->vt.params.idx == 0);
c += snprintf(&msg[c], sizeof(msg) - c, "%c", final);
snprintf(&msg[c], sizeof(msg) - c, "%c", final);
return msg;
}