From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (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 4949B4BCADD for ; Fri, 15 May 2026 16:50:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778863815; cv=none; b=QqUTBvFYzX0GYj0qt5Yp6Jpd7Hi2FujNpJBEsFgd/1SO5ytxV8K4k/tUdpTG9YRyL+jRp1JQuNsRAW72Juq4U7F+Hn1Bu8jnmZLU0kmPjTBePah3taJ5UH1G5f0ZHmiCeqXHq+TxgAPcuUMBPK4lg2pts8Ryjp+Shlat4iakPJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778863815; c=relaxed/simple; bh=tH5WJ66QRToRkxKMi5CzlJ8nS5W/lCMqd4UDM9GQwkU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EpMIh1K9oHrgB7d5BnKIO40j7Kw2KDNVNmschk6o0wJnN1kXjYaL7bntE/901IOTUl6a83rzNB4WaAgvHuLMzp2vp1sWeOI7k1Ib42PwEpOzCXTInITBBO8bT9T+Y+IMY/cNrISO23iiyiWsD++pfVmuamPqStUKtUxnSTaqqjQ= 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=O/DasoEo; arc=none smtp.client-ip=95.215.58.173 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="O/DasoEo" 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=1778863811; 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=xTOuacRFqf7jRiO8aj4MgPqi+i+IVWIh9egGsHuyaHw=; b=O/DasoEoGDcTGx8ffmNX0/z9Uv2PDz9BqNwqyFXWyFtqDlMtS2AWCgcf7ja++6/yVQcuyA 9MmPEE2neYO6FbkDr++2X9oikz5OajuiUrTa0/YkggVjws+TZ2M5oHCtndMdoyxJPl/doN U/OSHy/veaWlVjiIXYyFzTeKOd5OEAw= From: Thorsten Blum To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Andrew Morton , Breno Leitao , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Song Shuai , Pasha Tatashin , Alexander Graf Cc: Thorsten Blum , Alexandre Ghiti , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] riscv: kexec: use min to simplify riscv_kexec_elf_load Date: Fri, 15 May 2026 18:49:40 +0200 Message-ID: <20260515164944.574460-2-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=1420; i=thorsten.blum@linux.dev; h=from:subject; bh=tH5WJ66QRToRkxKMi5CzlJ8nS5W/lCMqd4UDM9GQwkU=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFnsfiv1s8/Nd8mM/xnA4uggeuSVx1zVNcJG9b8VjuhPO Cw3My2io5SFQYyLQVZMkeXBrB8zfEtrKjeZROyEmcPKBDKEgYtTACZyOZXhf9bXVe4zdBgfWmxd 6Xbwt6NtaNmcrHlLnHcvNtZdFpyeyc7wP8qL/9vbS2+mz9pbWFpRt+vbn09mm6XOiLxi+yskKJI rzgYA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Use min() to replace the open-coded version and assign the result directly to kbuf.bufsz. Drop the now-unused local size variable. Signed-off-by: Thorsten Blum --- arch/riscv/kernel/kexec_elf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/arch/riscv/kernel/kexec_elf.c b/arch/riscv/kernel/kexec_elf.c index 531d348db84d..528141df90ba 100644 --- a/arch/riscv/kernel/kexec_elf.c +++ b/arch/riscv/kernel/kexec_elf.c @@ -19,6 +19,7 @@ #include #include #include +#include #include static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr, @@ -27,7 +28,6 @@ static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr, { int i; int ret = 0; - size_t size; struct kexec_buf kbuf = {}; const struct elf_phdr *phdr; @@ -38,12 +38,8 @@ static int riscv_kexec_elf_load(struct kimage *image, struct elfhdr *ehdr, if (phdr->p_type != PT_LOAD) continue; - size = phdr->p_filesz; - if (size > phdr->p_memsz) - size = phdr->p_memsz; - kbuf.buffer = (void *) elf_info->buffer + phdr->p_offset; - kbuf.bufsz = size; + kbuf.bufsz = min(phdr->p_filesz, phdr->p_memsz); kbuf.buf_align = phdr->p_align; kbuf.mem = phdr->p_paddr - old_pbase + new_pbase; kbuf.memsz = phdr->p_memsz;