From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9C84045B97; Tue, 22 Oct 2024 03:08:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 34BE8402BC; Tue, 22 Oct 2024 03:08:25 +0200 (CEST) Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) by mails.dpdk.org (Postfix) with ESMTP id 32D9240295 for ; Tue, 22 Oct 2024 03:08:24 +0200 (CEST) Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3e604425aa0so1446634b6e.0 for ; Mon, 21 Oct 2024 18:08:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1729559303; x=1730164103; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Ilv6rFuKD36voE0GsD+9FLdJCmjBcdtSSD0AMIEAMbE=; b=FDi8LJ+Pa6lJCob/L48sn3EIRjv72/3IUUkL1Ms5hVO386jyYIg4eU8C3z7ibJaWa6 PnUeMjwjnrDjQxw2EMSgjqeu3zdF7dZX6srh5/cEUlDPf1rA5ZzoCYGKPmKfAugCopjE Q+Euq63oH3ixxy+k9pMNsu/uDlr+8k2IwwWQ8hy+ONU7/ljYLojT4qJxxH9wl5YNwbQH AvlqdLt93her0m9jOeAt01naAA89TTpc3fDkVZKlMkKMPePT+lIJjVFXJftOWG4Uvp82 SME2+hu0L8j0IIbRFRUKJoF3BHPAJNJh309S1PJxLb5jIWW1MoT44bG8EUQWSxOeYXKb 9N0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729559303; x=1730164103; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ilv6rFuKD36voE0GsD+9FLdJCmjBcdtSSD0AMIEAMbE=; b=DGp/9Zosjlleb+k+SCG0252v7k+ZiQI9wTwL/cGO/FQlrHPao1lEX+Wr0iR8cZRR4W 1PbHnGE29OgHSq1lxb49RZyJ/2ATm+mERb51PuxG3eq6hX1Z167swS1NiEsCfkuYvvaH QPGJwiAoD47JfLo9mljBtECu2U8G8sTJVUyfyLC7Pgb8Fyx2PmqVSxOWACmrLeqwV2vC NqXdRK8jmQfEyfJcEGgfOjRPk++AMRKl11lOk8KjCnUVQS/NorIY9yC2gGfeScA1IUzv OGDVRHaz5wngRpVgN2r6HbLYZU9K8V6Ag3yrxoBrXYkojaBkkbeIFBWyrnWurxUcpei+ JkwQ== X-Gm-Message-State: AOJu0YwD1T26JKGtg9uIE23BsUVxkjQ8ytTlDiOFRUIz+BCoT2WVDxZA VYrE1bJEC8amX+QMxMWHSq4bY1DAnft61mxMzLCUFOb/Mh34MnrrEFV1xzgeB6k= X-Google-Smtp-Source: AGHT+IHKskZVME13b5KFQV6eZCtZMbK2o/c0+Sc0/atHljtjAIpK1drj5+m1wIbWJHFOEeXp7P1OJA== X-Received: by 2002:a05:6808:2e93:b0:3e6:10d1:ecb6 with SMTP id 5614622812f47-3e610d1eed1mr5347600b6e.28.1729559303192; Mon, 21 Oct 2024 18:08:23 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7eaeabc115dsm3802882a12.74.2024.10.21.18.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 18:08:22 -0700 (PDT) Date: Mon, 21 Oct 2024 18:08:20 -0700 From: Stephen Hemminger To: Isaac Boukris Cc: dev@dpdk.org Subject: Re: Use of strtok() in dpdk code Message-ID: <20241021180820.48c7bffd@hermes.local> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Mon, 21 Oct 2024 21:30:02 +0300 Isaac Boukris 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.