Skip to contentSkip to conversation

perf util config : Modify size factor of snprintf

PATCH Applied Sihyeon Jang 3 participants 4 messages Dec 1, 2018 – Dec 18, 2018 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf util config : Modify size factor of snprintf

According to definition of snprintf, it gets size factor including null('\0') byte.
So '-1' is not neccessary. Also it will be helpful unfied style with other cases. (eg. builtin-script.c)

Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/util/config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/config.c +2 -2
index 5ac157056cdf..bce980fa9f41 100644
@@ -811,14 +811,14 @@ int config_error_nonbool(const char *var)
 void set_buildid_dir(const char *dir)
 {
 	if (dir)
-		scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir);
+		scnprintf(buildid_dir, MAXPATHLEN, "%s", dir);
 
 	/* default to $HOME/.debug */
 	if (buildid_dir[0] == '\0') {
 		char *home = getenv("HOME");
 
 		if (home) {
-			snprintf(buildid_dir, MAXPATHLEN-1, "%s/%s",
+			snprintf(buildid_dir, MAXPATHLEN, "%s/%s",
 				 home, DEBUG_CACHE_DIR);
 		} else {
 			strncpy(buildid_dir, DEBUG_CACHE_DIR, MAXPATHLEN-1);
Signature · 1 line
2.17.1
maintainer Applied
#1 lore raw

Em Sun, Dec 02, 2018 at 12:46:03AM +0900, Sihyeon Jang escreveu:

Quoted 2 lines

According to definition of snprintf, it gets size factor including null('\0') byte.
So '-1' is not neccessary. Also it will be helpful unfied style with other cases. (eg. builtin-script.c)

Thanks, applied.

- Arnaldo

Quoted 30 lines
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
---
 tools/perf/util/config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/config.c +2 -2
index 5ac157056cdf..bce980fa9f41 100644
@@ -811,14 +811,14 @@ int config_error_nonbool(const char *var)
 void set_buildid_dir(const char *dir)
 {
 	if (dir)
-		scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir);
+		scnprintf(buildid_dir, MAXPATHLEN, "%s", dir);
 
 	/* default to $HOME/.debug */
 	if (buildid_dir[0] == '\0') {
 		char *home = getenv("HOME");
 
 		if (home) {
-			snprintf(buildid_dir, MAXPATHLEN-1, "%s/%s",
+			snprintf(buildid_dir, MAXPATHLEN, "%s/%s",
 				 home, DEBUG_CACHE_DIR);
 		} else {
 			strncpy(buildid_dir, DEBUG_CACHE_DIR, MAXPATHLEN-1);
Signature · 1 line
2.17.1
Signature · 1 line
- Arnaldo
#2 lore raw

[tip:perf/core] perf config: Modify size factor of snprintf

In reply to Sihyeon Jang
perf config: Modify size factor of snprintf
Commit-ID:  63ac3b59f0fba922f98537ada06bc2528d1d2702
Gitweb:     https://git.kernel.org/tip/63ac3b59f0fba922f98537ada06bc2528d1d2702
Author:     Sihyeon Jang <[email protected]>
AuthorDate: Sun, 2 Dec 2018 00:46:03 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 6 Dec 2018 16:43:27 -0300

perf config: Modify size factor of snprintf

According to definition of snprintf, it gets size factor including null('\0') byte. So '-1' is not neccessary. Also it will be helpful unfied style with other cases. (eg. builtin-script.c)

---
 tools/perf/util/config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/config.c +2 -2
index 3beb4cf44c31..1ea8f898f1a1 100644
@@ -815,14 +815,14 @@ int config_error_nonbool(const char *var)
 void set_buildid_dir(const char *dir)
 {
 	if (dir)
-		scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir);
+		scnprintf(buildid_dir, MAXPATHLEN, "%s", dir);
 
 	/* default to $HOME/.debug */
 	if (buildid_dir[0] == '\0') {
 		char *home = getenv("HOME");
 
 		if (home) {
-			snprintf(buildid_dir, MAXPATHLEN-1, "%s/%s",
+			snprintf(buildid_dir, MAXPATHLEN, "%s/%s",
 				 home, DEBUG_CACHE_DIR);
 		} else {
 			strncpy(buildid_dir, DEBUG_CACHE_DIR, MAXPATHLEN-1);
#3 lore raw

[tip:perf/core] perf config: Modify size factor of snprintf

In reply to Sihyeon Jang
perf config: Modify size factor of snprintf
Commit-ID:  75c375c0ae7cc75cec6683ee2539937c60c3e4af
Gitweb:     https://git.kernel.org/tip/75c375c0ae7cc75cec6683ee2539937c60c3e4af
Author:     Sihyeon Jang <[email protected]>
AuthorDate: Sun, 2 Dec 2018 00:46:03 +0900
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 17 Dec 2018 14:59:40 -0300

perf config: Modify size factor of snprintf

According to definition of snprintf, it gets size factor including null('\0') byte. So '-1' is not neccessary. Also it will be helpful unfied style with other cases. (eg. builtin-script.c)

---
 tools/perf/util/config.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/config.c +2 -2
index 3beb4cf44c31..1ea8f898f1a1 100644
@@ -815,14 +815,14 @@ int config_error_nonbool(const char *var)
 void set_buildid_dir(const char *dir)
 {
 	if (dir)
-		scnprintf(buildid_dir, MAXPATHLEN-1, "%s", dir);
+		scnprintf(buildid_dir, MAXPATHLEN, "%s", dir);
 
 	/* default to $HOME/.debug */
 	if (buildid_dir[0] == '\0') {
 		char *home = getenv("HOME");
 
 		if (home) {
-			snprintf(buildid_dir, MAXPATHLEN-1, "%s/%s",
+			snprintf(buildid_dir, MAXPATHLEN, "%s/%s",
 				 home, DEBUG_CACHE_DIR);
 		} else {
 			strncpy(buildid_dir, DEBUG_CACHE_DIR, MAXPATHLEN-1);