From 9293ed4628222ca4d618e2147c4db94e22106ae4 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Wed, 10 Apr 2024 06:52:59 +0530 Subject: src: avoid unnecessary sizeof() - 1 --- src/libnpass/libnpass.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/libnpass/libnpass.c') diff --git a/src/libnpass/libnpass.c b/src/libnpass/libnpass.c index b9ce58e..a918e77 100644 --- a/src/libnpass/libnpass.c +++ b/src/libnpass/libnpass.c @@ -46,14 +46,14 @@ int set_pass_dir(void) { env = getenv("XDG_DATA_HOME"); if (env) { - snprintf(pass_dir, sizeof(pass_dir) - 1, "%s/%s", env, + snprintf(pass_dir, sizeof(pass_dir), "%s/%s", env, DEF_PASS_DIR); return 0; } env = getenv("HOME"); if (env) { - snprintf(pass_dir, sizeof(pass_dir) - 1, "%s/%s/%s", env, + snprintf(pass_dir, sizeof(pass_dir), "%s/%s/%s", env, ".local/share", DEF_PASS_DIR); return 0; } @@ -104,7 +104,7 @@ pass_store_t pass_store_type(const char *spath) { if (r) err_ret(PASS_STORE_INV, "PASSWORD_STORE_DIR not set"); - r = snprintf(abs_path, sizeof(abs_path) - 1, "%s/%s", + r = snprintf(abs_path, sizeof(abs_path), "%s/%s", pass_dir, (spath) ? spath : ""); if (r >= (int) sizeof(abs_path)) err_ret(PASS_STORE_INV, "path exceeded PATH_MAX"); @@ -112,7 +112,7 @@ pass_store_t pass_store_type(const char *spath) { if (!r && (sbuf.st_mode & S_IFMT) == S_IFDIR) return PASS_STORE_DIR; - r = snprintf(abs_path, sizeof(abs_path) - 1, "%s/%s.gpg", + r = snprintf(abs_path, sizeof(abs_path), "%s/%s.gpg", pass_dir, spath); if (r >= (int) sizeof(abs_path)) err_ret(PASS_STORE_INV, "path exceeded PATH_MAX"); @@ -139,7 +139,7 @@ DIR *openstore(const char *spath) { err_ret(NULL, "%s is not a passwordstore directory", spath); if (spath) { - r = snprintf(abs_path, sizeof(abs_path) - 1, "%s/%s", + r = snprintf(abs_path, sizeof(abs_path), "%s/%s", pass_dir, spath); if (r >= (int) sizeof(abs_path)) err_ret(NULL, "path exceeded PATH_MAX"); @@ -173,7 +173,7 @@ int readstore(DIR *dirp, struct store *s) { return EOF; } - strncpy(s->name , dir->d_name, sizeof(s->name)); + strncpy(s->name , dir->d_name, sizeof(s->name) - 1); switch (dir->d_type) { case DT_DIR: s->type = PASS_STORE_DIR; -- cgit v1.2.3