From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 4B6D51F1534 for ; Fri, 26 Jun 2026 18:48:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782499736; cv=none; b=uHHWHDxre9YiRQav561WhDSKgMqQxN7ENYesDRpvuidZENVO832d2419hFJYHPKrJDRrVUTb3bPeZJKnW8H0vJpLfAgYf0n2UAyd6s4ss23YBAb5HafZ8mkKJDbNYgkWm3/yIudrNO3YJ47GlIdgncBnoy2P2x9kWQEh3/qrFAc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782499736; c=relaxed/simple; bh=UUyEyLi2JOzXDLgwwRzK+qlFfg6Gn9vLkYBO0kIDLCs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=iTzRoXNOBoQ7+WFjaxZ2l4XV+vFcqjP7C3YjCw3hzsG/E93RAZxnV/G1dLdtI8RZ7t0Zu5VvxgeiJl+qUyFCrPz9R8LVUYgIwZVuJgP2lYrd8NMiL7VEFzWiFex67cm2BhH4QCc0IIChUfXlbgCKFlyYTNCralyuk6i5N9KAssQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=W0rrzsj+; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="W0rrzsj+" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1782499732; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ZsWyLvWJwqeNbF489UKOxlVtznFI97BRXUa6zN1YiSg=; b=W0rrzsj+q2Dk7PprwXObbdibAFQ+vyyp7gqqN+qhrQlMgG3o6gYgAgO/YvtygLhlT2CjDh qCJcQ8eOUdHBmPCY7Nk4ENY+jmNLZAK+CzfZKi+YHPESRwDpCzdsGg23sVYVmIsQpkC6QV T9iZ4QLuR3B4quo24XbkZOWgOV+s3gc= From: Thorsten Blum To: Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , Tyrel Datwyler , Mahesh Salgaonkar , Haren Myneni Cc: Thorsten Blum , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] powerpc/rtasd: Use struct_size() to simplify log_rtas_len() Date: Fri, 26 Jun 2026 20:47:49 +0200 Message-ID: <20260626184750.166642-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1702; i=thorsten.blum@linux.dev; h=from:subject; bh=UUyEyLi2JOzXDLgwwRzK+qlFfg6Gn9vLkYBO0kIDLCs=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFl2J8M6s7af01Va621fOCGZ20nizl5+uyupzw+35mreZ Hxb8udkRykLgxgXg6yYIsuDWT9m+JbWVG4yidgJM4eVCWQIAxenAExEzZ6RoSfnteAbawNGecUr j35KhBgc+3TSeccanrm6vD/XOnT+f8jwT/epuvglzwqT0EncHFoVUVGTtc6ztFl6XU1bsFVNYJ4 0DwA= X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Now that struct rtas_error_log uses a flexible array member for the extended log buffer, use struct_size() to calculate the total RTAS error log size and avoid using the hard-coded header size of 8 bytes. Use min() to replace the open-coded implementation while at it. Signed-off-by: Thorsten Blum --- arch/powerpc/kernel/rtasd.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c index 6336ec9aedd0..fd40864bdb70 100644 --- a/arch/powerpc/kernel/rtasd.c +++ b/arch/powerpc/kernel/rtasd.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -160,25 +161,17 @@ static void printk_log_rtas(char *buf, int len) static int log_rtas_len(char * buf) { - int len; + size_t len; struct rtas_error_log *err; - uint32_t extended_log_length; + u32 extended_log_length; - /* rtas fixed header */ - len = 8; err = (struct rtas_error_log *)buf; - extended_log_length = rtas_error_extended_log_length(err); - if (rtas_error_extended(err) && extended_log_length) { - - /* extended header */ - len += extended_log_length; - } + extended_log_length = rtas_error_extended(err) ? rtas_error_extended_log_length(err) : 0; + len = struct_size(err, buffer, extended_log_length); if (rtas_error_log_max == 0) rtas_error_log_max = rtas_get_error_log_max(); - - if (len > rtas_error_log_max) - len = rtas_error_log_max; + len = min(len, rtas_error_log_max); return len; }