1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-11-04 05:22:01 +03:00

clean: drop unneeded -1 for snprintf

man gives:
snprintf() and vsnprintf() write at most size bytes
(including the terminating null byte ('\0')) to str.
This commit is contained in:
Zdenek Kabelac 2018-02-12 21:50:07 +01:00
parent d94036f8ed
commit 7239a45b79
7 changed files with 8 additions and 9 deletions

View File

@ -2432,7 +2432,7 @@ static response get_global_info(lvmetad_state *s, request r)
pid = (int)daemon_request_int(r, "pid", 0);
if (s->flags & GLFL_DISABLE) {
snprintf(reason, REASON_BUF_SIZE - 1, "%s%s%s%s%s",
snprintf(reason, REASON_BUF_SIZE, "%s%s%s%s%s",
(s->flags & GLFL_DISABLE_REASON_DIRECT) ? LVMETAD_DISABLE_REASON_DIRECT "," : "",
(s->flags & GLFL_DISABLE_REASON_REPAIR) ? LVMETAD_DISABLE_REASON_REPAIR "," : "",
(s->flags & GLFL_DISABLE_REASON_LVM1) ? LVMETAD_DISABLE_REASON_LVM1 "," : "",

View File

@ -699,7 +699,7 @@ int lm_hosts_dlm(struct lockspace *ls, int notify)
return 0;
memset(ls_nodes_path, 0, sizeof(ls_nodes_path));
snprintf(ls_nodes_path, PATH_MAX-1, "%s/%s/nodes",
snprintf(ls_nodes_path, PATH_MAX, "%s/%s/nodes",
DLM_LOCKSPACES_PATH, ls->name);
if (!(ls_dir = opendir(ls_nodes_path)))

View File

@ -1069,10 +1069,10 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls)
* and appending "lockctl" to get /path/to/lvmlockctl.
*/
memset(killpath, 0, sizeof(killpath));
snprintf(killpath, SANLK_PATH_LEN - 1, "%slockctl", LVM_PATH);
snprintf(killpath, SANLK_PATH_LEN, "%slockctl", LVM_PATH);
memset(killargs, 0, sizeof(killargs));
snprintf(killargs, SANLK_PATH_LEN - 1, "--kill %s", ls->vg_name);
snprintf(killargs, SANLK_PATH_LEN, "--kill %s", ls->vg_name);
rv = check_args_version(ls->vg_args, VG_LOCK_ARGS_MAJOR);
if (rv < 0) {

View File

@ -606,7 +606,7 @@ int module_present(struct cmd_context *cmd, const char *target_name)
#endif
struct stat st;
char path[PATH_MAX];
int i = dm_snprintf(path, (sizeof(path) - 1), "%smodule/dm_%s",
int i = dm_snprintf(path, sizeof(path), "%smodule/dm_%s",
dm_sysfs_dir(), target_name);
if (i > 0) {

View File

@ -244,7 +244,7 @@ static int _line_append(struct config_output *out, const char *fmt, ...)
*/
va_start(ap, fmt);
n = vsnprintf(&buf[0], sizeof buf - 1, fmt, ap);
n = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
if (n < 0) {

View File

@ -187,8 +187,7 @@ retry_fcntl:
goto fail_close_unlink;
}
memset(buffer, 0, sizeof(buffer));
snprintf(buffer, sizeof(buffer)-1, "%u\n", getpid());
snprintf(buffer, sizeof(buffer), "%u\n", getpid());
bufferlen = strlen(buffer);
write_out = write(fd, buffer, bufferlen);

View File

@ -611,7 +611,7 @@ const char *dm_size_to_string(struct dm_pool *mem, uint64_t size,
precision = 2;
}
snprintf(size_buf, SIZE_BUF - 1, "%s%.*f%s", prefix, precision,
snprintf(size_buf, SIZE_BUF, "%s%.*f%s", prefix, precision,
(double) size / byte, include_suffix ? size_str[base + s][suffix_type] : "");
return size_buf;