Repository : ssh://git@open-mesh.org/batctl
On branch : next
commit 55509e580241c1483ea406a11aedc412c9b0a7d1 Author: Sven Eckelmann sven@narfation.org Date: Tue Sep 10 23:11:54 2013 +0200
batctl: Avoid assigning const buffer to non-const pointer
Strings in C are tried to be saved in the .rodata by the compiler/linker. This section is readonly as the name suggests. Pointer to these strings should therefore be const.
Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Marek Lindner mareklindner@neomailbox.ch
55509e580241c1483ea406a11aedc412c9b0a7d1 functions.c | 8 +++++--- functions.h | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/functions.c b/functions.c index 2a2f392..bd4da59 100644 --- a/functions.c +++ b/functions.c @@ -124,7 +124,8 @@ int file_exists(const char *fpath) return stat(fpath, &st) == 0; }
-static void file_open_problem_dbg(char *dir, char *fname, char *full_path) +static void file_open_problem_dbg(const char *dir, const char *fname, + const char *full_path) { const char **ptr; struct stat st; @@ -162,7 +163,7 @@ static void file_open_problem_dbg(char *dir, char *fname, char *full_path) } }
-int read_file(char *dir, char *fname, int read_opt, +int read_file(const char *dir, const char *fname, int read_opt, float orig_timeout, float watch_interval, size_t header_lines) { struct ether_addr *mac_addr; @@ -296,7 +297,8 @@ out: return res; }
-int write_file(char *dir, char *fname, char *arg1, char *arg2) +int write_file(const char *dir, const char *fname, const char *arg1, + const char *arg2) { int fd = 0, res = EXIT_FAILURE; char full_path[500]; diff --git a/functions.h b/functions.h index d88c494..f9c8191 100644 --- a/functions.h +++ b/functions.h @@ -34,9 +34,10 @@ char *ether_ntoa_long(const struct ether_addr *addr); char *get_name_by_macaddr(struct ether_addr *mac_addr, int read_opt); char *get_name_by_macstr(char *mac_str, int read_opt); int file_exists(const char *fpath); -int read_file(char *dir, char *path, int read_opt, +int read_file(const char *dir, const char *path, int read_opt, float orig_timeout, float watch_interval, size_t header_lines); -int write_file(char *dir, char *fname, char *arg1, char *arg2); +int write_file(const char *dir, const char *fname, const char *arg1, + const char *arg2); struct ether_addr *translate_mac(char *mesh_iface, struct ether_addr *mac); struct ether_addr *resolve_mac(const char *asc);