From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from 69-171-232-181.mail-mxout.facebook.com (69-171-232-181.mail-mxout.facebook.com [69.171.232.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B29793451AF for ; Fri, 20 Mar 2026 19:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=69.171.232.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774033791; cv=none; b=KFtg57eGl/oQv7EdH2/O00dNUuqrWDeZ0AopTy8e1tTD7jNBnubetsmTPqyz/spyqRynm0RuqIFfNW5KHBCTHUWCXbnSHRsqOFW5E8BObIGkPLxsNOgcaLu4bJUhi0CHQEt/l4yxOnIIZnq+VmEeFEKEWb0wEwVrZcKYb57lcYI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774033791; c=relaxed/simple; bh=bo/MaOhk8Q3JfGqgvsrdNG+xK8ZGfOtisOHwWx9q7hw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gyRZCVwRFsenWtgaIlMMP1yaoejpgr0CKQ7PfUOwa+ByFrvxPYlGG0ZwtXSYf5mbfzvzK8X4NLFiX8i2L8RvJjIkYOXPvk5ZqlPe/ecyZGW61a/Lq6wCi5nqzOy64lABGDYreyHhaJf7bu1uGxuu0xQ+pufZA8VZ02pb005cWxw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev; spf=fail smtp.mailfrom=linux.dev; arc=none smtp.client-ip=69.171.232.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.dev Received: by devvm16039.vll0.facebook.com (Postfix, from userid 128203) id E31B72A7EAD1E; Fri, 20 Mar 2026 12:09:32 -0700 (PDT) From: Yonghong Song To: Alan Maguire , Arnaldo Carvalho de Melo , dwarves@vger.kernel.org Cc: Alexei Starovoitov , Andrii Nakryiko , bpf@vger.kernel.org, kernel-team@fb.com Subject: [PATCH dwarves v3 3/9] dwarf_loader: Refactor initial ret -1 to be macro PARM_DEFAULT_FAIL Date: Fri, 20 Mar 2026 12:09:32 -0700 Message-ID: <20260320190932.1970971-1-yonghong.song@linux.dev> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260320190917.1970524-1-yonghong.song@linux.dev> References: <20260320190917.1970524-1-yonghong.song@linux.dev> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Later on, More macro return values will be implemented to make code easier to understand. Signed-off-by: Yonghong Song --- dwarf_loader.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dwarf_loader.c b/dwarf_loader.c index a6e6587..7b3f551 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -1195,12 +1195,14 @@ struct func_info { int skip_idx; }; =20 +#define PARM_DEFAULT_FAIL -1 + /* For DW_AT_location 'attr': * - if first location is DW_OP_regXX with expected number, return the r= egister; * otherwise save the register for later return * - if location DW_OP_entry_value(DW_OP_regXX) with expected number is = in the * list, return the register; otherwise save register for later return - * - otherwise if no register was found for locations, return -1. + * - otherwise if no register was found for locations, return PARM_DEFAU= LT_FAIL. */ static int parameter__reg(Dwarf_Attribute *attr, int expected_reg) { @@ -1210,7 +1212,7 @@ static int parameter__reg(Dwarf_Attribute *attr, in= t expected_reg) size_t exprlen, entry_len; ptrdiff_t offset =3D 0; int loc_num =3D -1; - int ret =3D -1; + int ret =3D PARM_DEFAULT_FAIL; =20 /* use libdw__lock as dwarf_getlocation(s) has concurrency issues * when libdw is not compiled with experimental --enable-thread-safety @@ -1327,7 +1329,7 @@ static struct parameter *parameter__new(Dwarf_Die *= die, struct cu *cu, int expected_reg =3D cu->register_params[reg_idx]; int actual_reg =3D parameter__reg(&attr, expected_reg); =20 - if (actual_reg < 0) + if (actual_reg =3D=3D PARM_DEFAULT_FAIL) parm->optimized =3D 1; else if (expected_reg >=3D 0 && expected_reg !=3D actual_reg) /* mark parameters that use an unexpected --=20 2.52.0