mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +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:
parent
d94036f8ed
commit
7239a45b79
@ -2432,7 +2432,7 @@ static response get_global_info(lvmetad_state *s, request r)
|
|||||||
pid = (int)daemon_request_int(r, "pid", 0);
|
pid = (int)daemon_request_int(r, "pid", 0);
|
||||||
|
|
||||||
if (s->flags & GLFL_DISABLE) {
|
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_DIRECT) ? LVMETAD_DISABLE_REASON_DIRECT "," : "",
|
||||||
(s->flags & GLFL_DISABLE_REASON_REPAIR) ? LVMETAD_DISABLE_REASON_REPAIR "," : "",
|
(s->flags & GLFL_DISABLE_REASON_REPAIR) ? LVMETAD_DISABLE_REASON_REPAIR "," : "",
|
||||||
(s->flags & GLFL_DISABLE_REASON_LVM1) ? LVMETAD_DISABLE_REASON_LVM1 "," : "",
|
(s->flags & GLFL_DISABLE_REASON_LVM1) ? LVMETAD_DISABLE_REASON_LVM1 "," : "",
|
||||||
|
@ -699,7 +699,7 @@ int lm_hosts_dlm(struct lockspace *ls, int notify)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
memset(ls_nodes_path, 0, sizeof(ls_nodes_path));
|
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);
|
DLM_LOCKSPACES_PATH, ls->name);
|
||||||
|
|
||||||
if (!(ls_dir = opendir(ls_nodes_path)))
|
if (!(ls_dir = opendir(ls_nodes_path)))
|
||||||
|
@ -1069,10 +1069,10 @@ int lm_prepare_lockspace_sanlock(struct lockspace *ls)
|
|||||||
* and appending "lockctl" to get /path/to/lvmlockctl.
|
* and appending "lockctl" to get /path/to/lvmlockctl.
|
||||||
*/
|
*/
|
||||||
memset(killpath, 0, sizeof(killpath));
|
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));
|
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);
|
rv = check_args_version(ls->vg_args, VG_LOCK_ARGS_MAJOR);
|
||||||
if (rv < 0) {
|
if (rv < 0) {
|
||||||
|
@ -606,7 +606,7 @@ int module_present(struct cmd_context *cmd, const char *target_name)
|
|||||||
#endif
|
#endif
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char path[PATH_MAX];
|
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);
|
dm_sysfs_dir(), target_name);
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
@ -244,7 +244,7 @@ static int _line_append(struct config_output *out, const char *fmt, ...)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
n = vsnprintf(&buf[0], sizeof buf - 1, fmt, ap);
|
n = vsnprintf(buf, sizeof(buf), fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
|
@ -187,8 +187,7 @@ retry_fcntl:
|
|||||||
goto fail_close_unlink;
|
goto fail_close_unlink;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buffer, 0, sizeof(buffer));
|
snprintf(buffer, sizeof(buffer), "%u\n", getpid());
|
||||||
snprintf(buffer, sizeof(buffer)-1, "%u\n", getpid());
|
|
||||||
|
|
||||||
bufferlen = strlen(buffer);
|
bufferlen = strlen(buffer);
|
||||||
write_out = write(fd, buffer, bufferlen);
|
write_out = write(fd, buffer, bufferlen);
|
||||||
|
@ -611,7 +611,7 @@ const char *dm_size_to_string(struct dm_pool *mem, uint64_t size,
|
|||||||
precision = 2;
|
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] : "");
|
(double) size / byte, include_suffix ? size_str[base + s][suffix_type] : "");
|
||||||
|
|
||||||
return size_buf;
|
return size_buf;
|
||||||
|
Loading…
Reference in New Issue
Block a user