From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 6/6] batctl: Convert strtok to reentrant safe strtok_r
Date: Sat, 30 Oct 2010 17:00:58 +0200 [thread overview]
Message-ID: <1288450858-14753-6-git-send-email-sven.eckelmann@gmx.de> (raw)
In-Reply-To: <1288450858-14753-1-git-send-email-sven.eckelmann@gmx.de>
Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de>
---
batctl/bisect.c | 10 +++++-----
batctl/vis.c | 12 ++++++------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/batctl/bisect.c b/batctl/bisect.c
index 2fa15f0..b7d8969 100644
--- a/batctl/bisect.c
+++ b/batctl/bisect.c
@@ -466,7 +466,7 @@ err:
static int parse_log_file(char *file_path)
{
FILE *fd;
- char line_buff[MAX_LINE], *start_ptr, *tok_ptr;
+ char line_buff[MAX_LINE], *start_ptr, *start_ptr_safe, *tok_ptr;
char *neigh, *iface_addr, *orig, *prev_sender, rt_flag;
int line_count = 0, tq, ttl, seqno, i, res, max;
@@ -483,12 +483,12 @@ static int parse_log_file(char *file_path)
line_count++;
if (strstr(start_ptr, "Received BATMAN packet via NB")) {
- tok_ptr = strtok(start_ptr, " ");
+ strtok_r(start_ptr, " ", &start_ptr_safe);
neigh = iface_addr = orig = prev_sender = NULL;
seqno = tq = ttl = -1;
for (i = 0; i < 21; i++) {
- tok_ptr = strtok(NULL, " ");
+ tok_ptr = strtok_r(NULL, " ", &start_ptr_safe);
if (!tok_ptr)
break;
@@ -547,11 +547,11 @@ static int parse_log_file(char *file_path)
max = 3;
}
- tok_ptr = strtok(start_ptr, " ");
+ strtok_r(start_ptr, " ", &start_ptr_safe);
orig = neigh = prev_sender = NULL;
for (i = 0; i < max; i++) {
- tok_ptr = strtok(NULL, " ");
+ tok_ptr = strtok_r(NULL, " ", &start_ptr_safe);
if (!tok_ptr)
break;
diff --git a/batctl/vis.c b/batctl/vis.c
index 4bc5954..7fba1ab 100644
--- a/batctl/vis.c
+++ b/batctl/vis.c
@@ -186,7 +186,7 @@ static int format(char *mesh_iface, const struct funcs *funcs)
char *line = NULL;
char *orig, *from;
char *duplet;
- char *line_save_ptr;
+ char *line_save_ptr, *component_save_ptr;
char *duplet_save_ptr;
char *endptr;
char *value;
@@ -207,12 +207,12 @@ static int format(char *mesh_iface, const struct funcs *funcs)
duplet_save_ptr = line_save_ptr;
while ((duplet = strtok_r(NULL, ",", &duplet_save_ptr)) != NULL) {
- flag = strtok(duplet, " ");
+ flag = strtok_r(duplet, " ", &component_save_ptr);
if (!flag)
continue;
if (!strcmp(flag, "TQ")) {
- from = strtok(NULL, " ");
- value = strtok(NULL, " ");
+ from = strtok_r(NULL, " ", &component_save_ptr);
+ value = strtok_r(NULL, " ", &component_save_ptr);
tq = strtoul(value, &endptr, 0);
funcs->print_tq(orig, from, tq);
continue;
@@ -221,13 +221,13 @@ static int format(char *mesh_iface, const struct funcs *funcs)
/* We have an HNA record */
if (!with_HNA)
continue;
- from = strtok(NULL, " ");
+ from = strtok_r(NULL, " ", &component_save_ptr);
funcs->print_HNA(orig, from);
continue;
}
if (!strcmp(flag, "SEC") && with_2nd) {
/* We found a secondary interface MAC address. */
- from = strtok(NULL, " ");
+ from = strtok_r(NULL, " ", &component_save_ptr);
funcs->print_2nd(orig, from);
}
if (!strcmp(flag, "PRIMARY") && with_2nd) {
--
1.7.2.3
next prev parent reply other threads:[~2010-10-30 15:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-30 15:00 [B.A.T.M.A.N.] [PATCH 1/6] batctl: Correct format strings for 8 bit ttl Sven Eckelmann
2010-10-30 15:00 ` [B.A.T.M.A.N.] [PATCH 2/6] batctl: Don't print uninitialised traceroute times Sven Eckelmann
2010-10-30 15:00 ` [B.A.T.M.A.N.] [PATCH 3/6] batctl: Remove unused variables Sven Eckelmann
2010-11-01 11:26 ` Marek Lindner
2010-11-01 11:34 ` Sven Eckelmann
2010-11-01 11:48 ` [B.A.T.M.A.N.] [PATCHv2 " Sven Eckelmann
2010-10-30 15:00 ` [B.A.T.M.A.N.] [PATCH 4/6] batctl: Initialise timeout before usage in error case Sven Eckelmann
2010-10-30 15:00 ` [B.A.T.M.A.N.] [PATCH 5/6] batctl: Readd ping interval after each loop Sven Eckelmann
2010-10-30 15:00 ` Sven Eckelmann [this message]
2010-11-04 14:05 ` [B.A.T.M.A.N.] [PATCH 1/6] batctl: Correct format strings for 8 bit ttl Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1288450858-14753-6-git-send-email-sven.eckelmann@gmx.de \
--to=sven.eckelmann@gmx.de \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).