Skip to contentSkip to conversation

alfred: Remove manual \0 terminator after snprintf

PATCH Applied Sven Eckelmann 2 participants 2 messages Mar 17, 2015 – Mar 19, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alfred: Remove manual \0 terminator after snprintf

snprintf already guarantees \0 terminated strings for size arguments is > 0.

---
 debugfs.c | 1 -
 vis/vis.c | 3 ---
 2 files changed, 4 deletions(-)
debugfs.c +0 -1
index fbf992e..6404b49 100644
@@ -58,7 +58,6 @@ int debugfs_make_path(const char *fmt, const char *mesh_iface, char *buffer,
 		return len+1;
 
 	snprintf(buffer, size-1, fmt, debugfs_mountpoint, mesh_iface);
-	buffer[size - 1] = '\0';
 	return 0;
 }
 
vis/vis.c +0 -3
index 4a14e66..c1f8dad 100644
@@ -274,7 +274,6 @@ static int register_interfaces(struct globals *globals)
 
 	while ((iface_dir = readdir(iface_base_dir)) != NULL) {
 		snprintf(path_buff, PATH_BUFF_LEN, SYS_MESH_IFACE_FMT, iface_dir->d_name);
-		path_buff[PATH_BUFF_LEN - 1] = '\0';
 		file_content = read_file(path_buff);
 		if (!file_content)
 			continue;
@@ -292,7 +291,6 @@ static int register_interfaces(struct globals *globals)
 		file_content = NULL;
 
 		snprintf(path_buff, PATH_BUFF_LEN, SYS_IFACE_STATUS_FMT, iface_dir->d_name);
-		path_buff[PATH_BUFF_LEN - 1] = '\0';
 		file_content = read_file(path_buff);
 		if (!file_content)
 			continue;
@@ -328,7 +326,6 @@ static int parse_orig_list(struct globals *globals)
 	struct vis_list_entry *v_entry;
 
 	snprintf(path, sizeof(path), "/sys/kernel/debug/batman_adv/%s/originators", globals->interface);
-	path[sizeof(path) - 1] = 0;
 	fbuf = read_file(path);
 	if (!fbuf)
 		return -1;
Signature · 1 line
2.1.4