From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C29208248B for ; Tue, 25 Nov 2025 00:46:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764031595; cv=none; b=pxv6lWq6iWQABiHgiaYH+hfqfLZLY6eidH7As0TnK0ozDcpz5XyXWRFHed44Jw1+6CzQRK1RjzjjItjPBD5dKEh2vhMP+r6hfI0vCsRavV4hhEU+gpukF/87wBq4RB3RfHOUqV/jRI8plccFU7anYI9Js0ip8xml6FV+h3ULVDU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764031595; c=relaxed/simple; bh=Y0rWlV+eyfJjYlqL7oYDum80s2kVae3QQklWUjodGJ0=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References: Content-Type:MIME-Version; b=YDyi3UoTYvqn56Mtu7uy0u7C6Vydkp1y8ntHplHdn3n4XrJiCW1W6CZlzldAOn3BmrbtP5aMXzzT0V2XwqhGpEED40DuJMJ3zWLWw6p6asukNtsAaFC+Qo4UUBXa/sQH6kHaNudUo3Z3roC7jZ1N4dC75HLXrPVqhLcPiA09f9E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NmR6Pl2j; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=VTfFvTL2; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NmR6Pl2j"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="VTfFvTL2" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764031592; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ncItnG6r8wEZMryKPwalIeSOSpPfyXeplwJX6HDv+pg=; b=NmR6Pl2jfQx85gX0Dp0p6uJDtFYk+03BH2xxsQ5S6hAVVpLo1So6xUvoFeM8vyRIelOO24 I7p3JWtr96XsUReckrw6aOFuRwWThmLp0VcN83eE/RdhwGetpNYlX0ZqnIytnUCY5U/oxM 6rX3GwpoDsI8/9z9O1rDWdVLek+VJTU= Received: from mail-qv1-f69.google.com (mail-qv1-f69.google.com [209.85.219.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-606-fmWwQqFAM0eZFTjbU7kADg-1; Mon, 24 Nov 2025 19:46:31 -0500 X-MC-Unique: fmWwQqFAM0eZFTjbU7kADg-1 X-Mimecast-MFC-AGG-ID: fmWwQqFAM0eZFTjbU7kADg_1764031591 Received: by mail-qv1-f69.google.com with SMTP id 6a1803df08f44-88239fa9ec9so141764426d6.2 for ; Mon, 24 Nov 2025 16:46:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1764031591; x=1764636391; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ncItnG6r8wEZMryKPwalIeSOSpPfyXeplwJX6HDv+pg=; b=VTfFvTL2vU3/c6oEKHPpXqpOyb9gRAAx0WYYT1AYr0sIaqZyEZsV2bUtn3PUVqgnG9 WDHBn3zcG2L1EHBx0jSJ2LTXL08HEPpbfnT5h0Z/Jz6mQf+0epXqO5DCXuB7W6cJoxMn 97g/sMNE02pngmRTXCdHb3xLuchC576+Ce5993hSwWov1AWG6kRmqewtGrV7zm8VZFgG RMXGBHi+ACbt152/2E8EwZFiyej6MX6boInmhiM7teauf+J2mQkcD9PoLmdlbRSFVe8I 4LBcSSvsMZ+3Rq7Ie0KzOeqg0VFsT6208tgC04XhGX5nLEYznXp9/3k0ZKzpmyIOpRhg UjCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764031591; x=1764636391; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ncItnG6r8wEZMryKPwalIeSOSpPfyXeplwJX6HDv+pg=; b=R9vPNKMW8uq+Yhb5TIo9/xsIMflxzD8MQEGKgnJ9irsPfAOailRs8LgLa5dyKo3Frb x64HVEmHKP7D7uKLVXXVKSQ2EbkNPteX8xIbw/j0awQe2ObtcPhhIo526KpwGcCz6/wL 4tHbGPjIQqQO590cu9wmqTjnzuTwrm7hKaNQxThkRxM4/qUS3kA0m2Jc7boxCd3Kq2+8 yYfMfjs4R917I5nKrE3sN608Dt/MlkvvhQoDSo57wiXtdFw+rSHORFIDlJ4+RWuBIHRE 4Lf6e321v0UzBlobAwVP2jvfuJ3kpgbPDuhwxo0H5V/JEex9lEySUrrB80p2dxTIbgXL r3JA== X-Forwarded-Encrypted: i=1; AJvYcCXrcMUUDFyo+XILe1IH+yaosRMDlyeSKx56qvq3rIpL6VPstZ1kFvtM6XRV4hnapKe9bcUBRb1GgHcTpJw=@vger.kernel.org X-Gm-Message-State: AOJu0Yye80GDquz9KcjrlAixW0VUWHq5uiI946A2R5DWLUEV8cF7jlih s5Lch9NGOPPwqmUKDg1CqUXcZfW+3w3VvnxGNuCMx4CdfVkti5jFNWWCBZO7XQDPgGQi7EqK7hn ecWYkpqvLoHFRYr+jitjTVddJ+lNgMXycFIDvPaewPmKp5ICszuuEL6EnZHtyy2JWQ9kYS/F1yg == X-Gm-Gg: ASbGncvsqzFCJ1Ay6jqEM0lJNDCkYUer5VV8VCVDp7BJglbfH/M9WOSonLQ4ShZnh5J /dtd0YLwTRTbra+Uek19ZkCGe503y5NeQtc51f8RLmwu/qf/GdtopMcZ4TrNCg/v77l2IonVNkD daMv82ykfCI1YwKOuuQmngN3Y0qB0mS4vkk3WxqXBIsU3msSVF2CeIIHoWmG08iWL1O1UoBKgBE PbyyI4dRQQn+to5DY6m5ZkSJiHChjtgu/I7IO2QYPyzjCCWGLihqUA3XiPqsU2Fxy/03/0fuAJ1 OcGSCH9nVlXuptymaHOWmYFyH+1b2k+k3I37IILa/MfYG9wSWoKEGB97gcDFvotGQPOz6UVHgFv DrSjyem2OSMoSkFqc5btLfgy0bQpoTad8vL6hlswvPw== X-Received: by 2002:ad4:5bc3:0:b0:882:3ca2:f11f with SMTP id 6a1803df08f44-8847c4ca39cmr201790126d6.25.1764031590969; Mon, 24 Nov 2025 16:46:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHoEJaswoVSDH9fyyqjPDyF/mbttDXLpmbINV8TC0fuiCOS4UY50MM0uWdGNruKowqDwIYEeA== X-Received: by 2002:ad4:5bc3:0:b0:882:3ca2:f11f with SMTP id 6a1803df08f44-8847c4ca39cmr201789886d6.25.1764031590551; Mon, 24 Nov 2025 16:46:30 -0800 (PST) Received: from crwood-thinkpadp16vgen1.minnmso.csb ([2601:447:c680:2b50:ee6f:85c2:7e3e:ee98]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-8846e599978sm112470636d6.52.2025.11.24.16.46.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Nov 2025 16:46:30 -0800 (PST) Message-ID: <9770045bcf400920152f0698c07090a641cc4aa1.camel@redhat.com> Subject: Re: [rtla 04/13] rtla: Replace atoi() with a robust strtoi() From: Crystal Wood To: Wander Lairson Costa , Steven Rostedt , Tomas Glozar , Ivan Pravdin , John Kacur , Costa Shulyupin , Tiezhu Yang , "open list:Real-time Linux Analysis (RTLA) tools" , open list , "open list:BPF [MISC]:Keyword:(?:\\b|_)bpf(?:\\b|_)" Date: Mon, 24 Nov 2025 18:46:29 -0600 In-Reply-To: <20251117184409.42831-5-wander@redhat.com> References: <20251117184409.42831-1-wander@redhat.com> <20251117184409.42831-5-wander@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2025-11-17 at 15:41 -0300, Wander Lairson Costa wrote: >=20 > diff --git a/tools/tracing/rtla/src/actions.c b/tools/tracing/rtla/src/ac= tions.c > index efa17290926da..e23d4f1c5a592 100644 > --- a/tools/tracing/rtla/src/actions.c > +++ b/tools/tracing/rtla/src/actions.c > @@ -199,12 +199,14 @@ actions_parse(struct actions *self, const char *tri= gger, const char *tracefn) > /* Takes two arguments, num (signal) and pid */ > while (token !=3D NULL) { > if (strlen(token) > 4 && strncmp(token, "num=3D", 4) =3D=3D 0) { > - signal =3D atoi(token + 4); > + if(!strtoi(token + 4, &signal)) > + return -1; if ( > } else if (strlen(token) > 4 && strncmp(token, "pid=3D", 4) =3D=3D 0)= { > if (strncmp(token + 4, "parent", 7) =3D=3D 0) > pid =3D -1; > else > - pid =3D atoi(token + 4); > + if (!strtoi(token + 4, &pid)) > + return -1; else if ( Please run the patches through checkpatch.pl > @@ -959,3 +967,25 @@ int auto_house_keeping(cpu_set_t *monitored_cpus) > =20 > return 1; > } > + > +/* > + * strtoi - convert string to integer with error checking > + * > + * Returns true on success, false if conversion fails or result is out o= f int range. > + */ > +bool strtoi(const char *s, int *res) Could use __attribute__((__warn_unused_result__)) like kstrtoint(). BTW, it's pretty annoying that we need to reinvent the wheel on all this stuff just because it's userspace. From some of the other tools it looks like we can at least include basic kernel headers like compiler.h; maybe we should have a tools/-wide common util area as well? Even better if some of the code can be shared with the kernel itself. Not saying that should in any way be a blocker for these patches, just something to think about. -Crystal