dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Isaac Boukris <iboukris@gmail.com>
Cc: dev@dpdk.org
Subject: Re: Use of strtok() in dpdk code
Date: Mon, 21 Oct 2024 18:08:20 -0700	[thread overview]
Message-ID: <20241021180820.48c7bffd@hermes.local> (raw)
In-Reply-To: <CAC-fF8QK1UXKa7buuHojf7zMy5ptUro6tMLKTfuv5k012gKNpQ@mail.gmail.com>

On Mon, 21 Oct 2024 21:30:02 +0300
Isaac Boukris <iboukris@gmail.com> wrote:

> Hello,
> 
> I was debugging a crash resulting from strtok() returning NULL
> unexpectedly (string still had tokens and delimiters), and the only
> explanation I could come up with was that strtok is thread-unsafe and
> another thread could have been calling it at the same time, and so I
> changed it to use strtok_r().
> 
> That said, the only other possible use of strtok() that I could find
> was in the dpdk code (telemetry), which brings me to my question,
> should we consider changing all occurrences to strtok_r() or am I
> missing something? there seem to be quite some in non-initialization
> code.
> 
> Thanks!


Most of the uses are in tests and other single threaded code.
In general, simpler just to use strtok_r everywhere and not worry about it.
Similar to not using sprintf() and instead using snprintf().

Some code scanners like codeql also flag this.

  reply	other threads:[~2024-10-22  1:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21 18:30 Use of strtok() in dpdk code Isaac Boukris
2024-10-22  1:08 ` Stephen Hemminger [this message]
2024-10-22  6:51   ` fengchengwen
2024-10-22 12:27     ` Isaac Boukris
2024-10-22 15:25     ` Stephen Hemminger

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=20241021180820.48c7bffd@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=iboukris@gmail.com \
    /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).