From patchwork Fri Aug 11 21:19:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13351471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FFE4C0015E for ; Fri, 11 Aug 2023 21:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235948AbjHKVT3 (ORCPT ); Fri, 11 Aug 2023 17:19:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235638AbjHKVT2 (ORCPT ); Fri, 11 Aug 2023 17:19:28 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69F5F2108 for ; Fri, 11 Aug 2023 14:19:27 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-d630af4038fso2483469276.0 for ; Fri, 11 Aug 2023 14:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691788766; x=1692393566; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vokOFglu6CNVFlD6jFxpsLrBcNE5errPjKaL6LUnglg=; b=tOsdQnkRdFPySXJ7aBEL+kY5112HthEEIawDywYABXxp9YXRYroZTrYNW87VUbeR6w gnfsPvSydIxNPCx/RPtTkwb6RerMKsEuJIyl7U/C3waNbaU7wr0JImPoka2YzlVj0Ih8 6pjOc1L9fBFcSIVBUDCD8S6uX7hs8crgEnCNZot4mKk3eGHefKgu8OYgILc1VkUwX0Wl H7pBqE0CQNiBloC4RhooFEGfnMWOFZzd60L6EAZXRDFhGV2IqF04UdrS/6MXav7kuvc8 66Sk1UukGjP11WxYjJFMcVJQXQF9NcICKPD23LYMz+JPCT1jjKnprYFqeweidJ1zEKsy tNTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691788766; x=1692393566; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vokOFglu6CNVFlD6jFxpsLrBcNE5errPjKaL6LUnglg=; b=KqSzzqVb9kujfOVuJpeo+KaM/sTXCzTXBpZXKIMvv1XJ3oSjz0QIh8tfglBUzJk0gT soVghEK+yTutLiBJgkO6oo0tbv1obe/E3Obrt+CW1KA+wH98YxUcRwndHEJbVv7r0AjF 8oXeptuDS7OAu0xbG/CD48HlXiIdQzyBAWH52RPhI4hwc/YafyZkVpFf9te6XpoMIs3/ 9Y5EcvcruYdZdo7Q7QfJe42ygCqbULnBre7qQUHaB038vt9wdPlpVFmUamS6t0Y8RI58 xTa1G3Rd3gTxBMClXTd3w4jpYaKlrfJXKU3QYRYJIYzs6fdXsw/HA0pRIXtlzi18OWaQ YdIg== X-Gm-Message-State: AOJu0Yyz/8Re9Gftj48DW0VlVmN4fsczfbhKWvv8cF2MFXHYHl5t8bPs qf2iO8747Sxc0SX1k1DoEwYrhd+QkrlE3J1b8A== X-Google-Smtp-Source: AGHT+IH3i5ZHuMThcQNM8zp+I7k8FNd7+Of/quUCUxdMUbD/p45+H7KNRGfsu23iJhRFAio31HZ5RFrQ44ATxZZpGQ== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a25:dcc2:0:b0:d12:d6e4:a08f with SMTP id y185-20020a25dcc2000000b00d12d6e4a08fmr47833ybe.6.1691788766690; Fri, 11 Aug 2023 14:19:26 -0700 (PDT) Date: Fri, 11 Aug 2023 21:19:19 +0000 In-Reply-To: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-0-301052a5663e@google.com> Mime-Version: 1.0 References: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-0-301052a5663e@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1691788764; l=878; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=rykhGlCJgq/28Gofw5R06xkjvMhLluFR9H0cPPJUQmM=; b=dqa+uC3ZSEDoM05puhWT3wolaXk7hfvs4+6yIWB8tO66gB9QZCYN9RSLwV2BvBVVbMLw1tvkc 4a2Vy7MXx8vCn44O2/F7Pbs8dDN7gJ5VA3oINrtf5Q66VN6jNZDUZnG X-Mailer: b4 0.12.3 Message-ID: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-1-301052a5663e@google.com> Subject: [PATCH RFC 1/3] powerpc/ps3: refactor strncpy usage attempt 1 From: Justin Stitt To: Geoff Levand , Michael Ellerman , Nicholas Piggin , Christophe Leroy Cc: linux-hardening@vger.kernel.org, Kees Cook , Nick Desaulniers , Nathan Chancellor , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Justin Stitt Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org This approach simply replicates the implementation of `make_field` which means we drop `strncpy` for `memcpy`. Signed-off-by: Justin Stitt --- arch/powerpc/platforms/ps3/repository.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/ps3/repository.c b/arch/powerpc/platforms/ps3/repository.c index 205763061a2d..1abe33fbe529 100644 --- a/arch/powerpc/platforms/ps3/repository.c +++ b/arch/powerpc/platforms/ps3/repository.c @@ -73,9 +73,9 @@ static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4, static u64 make_first_field(const char *text, u64 index) { - u64 n; + u64 n = 0; - strncpy((char *)&n, text, 8); + memcpy((char *)&n, text, strnlen(text, sizeof(n))); return PS3_VENDOR_ID_NONE + (n >> 32) + index; } From patchwork Fri Aug 11 21:19:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13351470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7772EC04A6A for ; Fri, 11 Aug 2023 21:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235638AbjHKVTa (ORCPT ); Fri, 11 Aug 2023 17:19:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236260AbjHKVT3 (ORCPT ); Fri, 11 Aug 2023 17:19:29 -0400 Received: from mail-oa1-x4a.google.com (mail-oa1-x4a.google.com [IPv6:2001:4860:4864:20::4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71D9C2129 for ; Fri, 11 Aug 2023 14:19:28 -0700 (PDT) Received: by mail-oa1-x4a.google.com with SMTP id 586e51a60fabf-1c2be7624aaso1131406fac.2 for ; Fri, 11 Aug 2023 14:19:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691788767; x=1692393567; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=TQpId7/xrpQlCKdhMKKnoX3RMnX16k+BrWUnYQTLzJw=; b=uUhkhnABtd0vfm57xK91U6UrehuBrImq4ARCgRvPK1VtDSGUxYTRLzLYMyreywR/Kr pCh/hQNvbfipv3mKDUJiaDsvo3bwZHFN5pu4ewh1VNo2Z/YrRCpdGvV5/JbfP0XjLK+B hTVgKZVq/gLBU3Sv0VHPO3+NtyQwNyy0GsvpvmIn7HzktHQJ4p/loFJ6jZ1a7MeasZLO z+0b9LD/Vtn6c2AfA6PhS9bB+qCxbkjRGZAe9BqNRDmWmfjmbhOXDqaG1N7a9Sg73kQ8 PjsMTbRI3O7gBIRoVBbMfcwoYhB5aMR3pkUBYiAd7Ty4FOnlgscisSZ8zdUoBaUC+HXL SQLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691788767; x=1692393567; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=TQpId7/xrpQlCKdhMKKnoX3RMnX16k+BrWUnYQTLzJw=; b=Uzig0E1BI5jK4mhH492HWkJp6VuLN1VLFmblHeEoNzLa3mLTbFxys/ZEqIrivdK9lE nTvYZQ+50Ka3jt7hxl6EKXchhh+/E9KiV1NBWuOvVVpln6Jxf4PP5u48eImJBbNDWmKl ynfxK5LrDn7A6m5FaLXMt7pbnRa21zBSz8lPCRQvnOBhKstyKp5mDSZxOehd5oT3yYKp 05pBDnhe7vRApUReIhPWd4MdqsPfY7hUVWm7yfuPR0wmP/xIYOKyPqNDkg4I9MvjG/9a JJHVSQj5koPF1nMOWzVjlgzSWB8dd0K20hNttaj5NJ23CLdglOV3LjVV7PAxGRs/5mg5 mOAg== X-Gm-Message-State: AOJu0Yy7f/IoNzo0eBtex2cXdOIr6uiF0IaNvwDvkPBNrdR5rHi24zwR iOvS7bLCAtret67xIrWjMr8NpnipPpgMetOSaw== X-Google-Smtp-Source: AGHT+IGk1uf0kGWR1cjzqQP7AfmkJkzJDJmfyuKmDjGLWg1w0/gQx1YVAdwd/TAqEYcQ0G5w7a5EsM3oLCtnyG9dyA== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:6870:9567:b0:1c0:eac2:979c with SMTP id v39-20020a056870956700b001c0eac2979cmr65726oal.3.1691788767834; Fri, 11 Aug 2023 14:19:27 -0700 (PDT) Date: Fri, 11 Aug 2023 21:19:20 +0000 In-Reply-To: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-0-301052a5663e@google.com> Mime-Version: 1.0 References: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-0-301052a5663e@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1691788764; l=2495; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=OU2B7x8FNL1q157scUIMm8YAPWH0YRRYFkNwfqAAlYc=; b=t8i/MBrRZYTBCyZG+n62sm6BtF8rrxy6c3AXOklnMgD6g/y9j3NSShRjs0U3zb6DojFQXi7R6 t71tXOebyWwC4lP3GudY7BB2KoS2VPhOxRDI6pEsirAJWNJJ7/C+0lD X-Mailer: b4 0.12.3 Message-ID: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-2-301052a5663e@google.com> Subject: [PATCH RFC 2/3] powerpc/ps3: refactor strncpy usage attempt 2 From: Justin Stitt To: Geoff Levand , Michael Ellerman , Nicholas Piggin , Christophe Leroy Cc: linux-hardening@vger.kernel.org, Kees Cook , Nick Desaulniers , Nathan Chancellor , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Justin Stitt Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org This approach tries to use `make_field` inside of `make_first_field`. This comes with some weird implementation as to get the same result we need to first subtract `index` from the `make_field` result whilst being careful with order of operations. We then have to add index back. The behavior should be the same but would love some comments on this. Signed-off-by: Justin Stitt --- Note: I swapped the position of the two methods so as to not have to forward declare `make_field`. This results in a weird diff here. --- arch/powerpc/platforms/ps3/repository.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/platforms/ps3/repository.c b/arch/powerpc/platforms/ps3/repository.c index 1abe33fbe529..6b731a5d4adc 100644 --- a/arch/powerpc/platforms/ps3/repository.c +++ b/arch/powerpc/platforms/ps3/repository.c @@ -63,36 +63,33 @@ static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4, } /** - * make_first_field - Make the first field of a repository node name. - * @text: Text portion of the field. + * make_field - Make subsequent fields of a repository node name. + * @text: Text portion of the field. Use "" for 'don't care'. * @index: Numeric index portion of the field. Use zero for 'don't care'. * - * This routine sets the vendor id to zero (non-vendor specific). * Returns field value. */ -static u64 make_first_field(const char *text, u64 index) +static u64 make_field(const char *text, u64 index) { u64 n = 0; memcpy((char *)&n, text, strnlen(text, sizeof(n))); - return PS3_VENDOR_ID_NONE + (n >> 32) + index; + return n + index; } /** - * make_field - Make subsequent fields of a repository node name. - * @text: Text portion of the field. Use "" for 'don't care'. + * make_first_field - Make the first field of a repository node name. + * @text: Text portion of the field. * @index: Numeric index portion of the field. Use zero for 'don't care'. * + * This routine sets the vendor id to zero (non-vendor specific). * Returns field value. */ -static u64 make_field(const char *text, u64 index) +static u64 make_first_field(const char *text, u64 index) { - u64 n = 0; - - memcpy((char *)&n, text, strnlen(text, sizeof(n))); - return n + index; + return PS3_VENDOR_ID_NONE + ((make_field(text, index) - index) >> 32) + index; } /** From patchwork Fri Aug 11 21:19:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13351472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3265EC001DE for ; Fri, 11 Aug 2023 21:19:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236866AbjHKVTc (ORCPT ); Fri, 11 Aug 2023 17:19:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236875AbjHKVTa (ORCPT ); Fri, 11 Aug 2023 17:19:30 -0400 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C46F91FED for ; Fri, 11 Aug 2023 14:19:29 -0700 (PDT) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-586b0ef17daso66479797b3.1 for ; Fri, 11 Aug 2023 14:19:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691788769; x=1692393569; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=JiHGiTVfdz5CucudaZHkceNNqnAp127R9oXTgpxLmS0=; b=69/W2KdBUbTfVSLt7H2R1qqS3DXKFqFlWpbGW7Cg3ECEi8vGGHJaho4vRdFup3fEeV zVcU2qUDoBdNFmSOCqTHHDQHKg2IrdYm39Vt5gS5rz94OnIR7DEtN2lsAVmSb0Tqz0Ht Z5l8peAOiEHZtJ2Gklp82OPAuiBTHojD7Pg5Q7iZZcREV+yEUuxSLNG0n8waPGLDRreo a+NcGUKV8kMK8j8cMqGepg+/OizzIBECrGyezlwSfbYn9niSi09jOGbJhiGnOPkuEtJ8 YU/x8cXvc9erPDbri9oiyV6O0REpsuYGmemCP2W4ouJtR3u/tP7DEk/xn+Z9gKF0xqOQ LNpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691788769; x=1692393569; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JiHGiTVfdz5CucudaZHkceNNqnAp127R9oXTgpxLmS0=; b=fLuaYT9UM3G9Iznox5ZfK/tTTDtlSbqnVxh0tJZrGbJ1wWetyGRtQ1RGYifTWRl6Mg osxXGeQO2bwedcSx7cGJ/aX4pJJ5RkMm+uxymxh24SplcvXPCnRPE7qq/ph14bYvGIDN clVW1xH+dVH04szZK7B6Aq7e0Cp2XxminLL8o18CmrPPIMuuFt+p6b/hNoo6EP2iDUeX gFMeAiqeuL+VDr+05Nj8DrBjzoOzOEDjzQ3X4OP3MhLgqS/n0dtXATRYvCGwOy3v9z5C P2lAo7fi3iodnYKW5ZE09QpWuE4oJ9Hd0VPF4xYI0If+jJpdF+Cm9BeKQtFSjvvVKsnP Zbcw== X-Gm-Message-State: AOJu0Yy1TxGzxD/h18R6Pv2eZ/EbYIWXd+k1TC9H14pgs8h/dUvDkI+8 4UzDIPQlbVDa9Tt379uJALDpdbvqiBILQtk8zg== X-Google-Smtp-Source: AGHT+IHbwU50kF0vOvJsfl6xiGMeCABLjZMuvF4jlcuA/i0PNQczwluQDWHlLkKRUAyDj0PAcSup4QVhVi2nvA+/Lg== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a81:af49:0:b0:589:a610:aef with SMTP id x9-20020a81af49000000b00589a6100aefmr76862ywj.2.1691788769080; Fri, 11 Aug 2023 14:19:29 -0700 (PDT) Date: Fri, 11 Aug 2023 21:19:21 +0000 In-Reply-To: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-0-301052a5663e@google.com> Mime-Version: 1.0 References: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-0-301052a5663e@google.com> X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1691788764; l=2360; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=un5KrhEbUeSG5MIia1JYWEm7kQ5KlO4dof2rfH0SxB0=; b=3nGjJYu+m7uWyObArsWKunAcpSZnHjKe9mn5gkmY/yM21roqfaVuczXVmSVp0u0rKkq9+vbWf LjstrWwCo1OAJQJrgXlXQxNm1g4I4F9O5JB8O/Ope1+HZNTSmJBVJ/g X-Mailer: b4 0.12.3 Message-ID: <20230811-strncpy-arch-powerpc-platforms-ps3-v1-3-301052a5663e@google.com> Subject: [PATCH RFC 3/3] powerpc/ps3: refactor strncpy usage attempt 2.5 From: Justin Stitt To: Geoff Levand , Michael Ellerman , Nicholas Piggin , Christophe Leroy Cc: linux-hardening@vger.kernel.org, Kees Cook , Nick Desaulniers , Nathan Chancellor , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Justin Stitt Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Forward declare `make_field` for a cleaner diff Signed-off-by: Justin Stitt --- arch/powerpc/platforms/ps3/repository.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/arch/powerpc/platforms/ps3/repository.c b/arch/powerpc/platforms/ps3/repository.c index 6b731a5d4adc..6a08bb7704da 100644 --- a/arch/powerpc/platforms/ps3/repository.c +++ b/arch/powerpc/platforms/ps3/repository.c @@ -20,6 +20,8 @@ enum ps3_lpar_id { PS3_LPAR_ID_PME = 1, }; +static u64 make_field(const char *text, u64 index); + #define dump_field(_a, _b) _dump_field(_a, _b, __func__, __LINE__) static void _dump_field(const char *hdr, u64 n, const char *func, int line) { @@ -63,33 +65,33 @@ static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4, } /** - * make_field - Make subsequent fields of a repository node name. - * @text: Text portion of the field. Use "" for 'don't care'. + * make_first_field - Make the first field of a repository node name. + * @text: Text portion of the field. * @index: Numeric index portion of the field. Use zero for 'don't care'. * + * This routine sets the vendor id to zero (non-vendor specific). * Returns field value. */ -static u64 make_field(const char *text, u64 index) +static u64 make_first_field(const char *text, u64 index) { - u64 n = 0; - - memcpy((char *)&n, text, strnlen(text, sizeof(n))); - return n + index; + return PS3_VENDOR_ID_NONE + ((make_field(text, index) - index) >> 32) + index; } /** - * make_first_field - Make the first field of a repository node name. - * @text: Text portion of the field. + * make_field - Make subsequent fields of a repository node name. + * @text: Text portion of the field. Use "" for 'don't care'. * @index: Numeric index portion of the field. Use zero for 'don't care'. * - * This routine sets the vendor id to zero (non-vendor specific). * Returns field value. */ -static u64 make_first_field(const char *text, u64 index) +static u64 make_field(const char *text, u64 index) { - return PS3_VENDOR_ID_NONE + ((make_field(text, index) - index) >> 32) + index; + u64 n = 0; + + memcpy((char *)&n, text, strnlen(text, sizeof(n))); + return n + index; } /**