Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753304AbbBXQVK (ORCPT ); Tue, 24 Feb 2015 11:21:10 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:29158 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752549AbbBXQVJ (ORCPT ); Tue, 24 Feb 2015 11:21:09 -0500 Date: Tue, 24 Feb 2015 17:22:58 +0100 From: Quentin Casasnovas To: Borislav Petkov Cc: X86 ML , LKML , Quentin Casasnovas Subject: Re: [PATCH 05/13] x86/microcode/intel: Make _save_mc() return the updated saved count Message-ID: <20150224162258.GF4565@chrystal.uk.oracle.com> References: <1424774232-5981-1-git-send-email-bp@alien8.de> <1424774232-5981-6-git-send-email-bp@alien8.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424774232-5981-6-git-send-email-bp@alien8.de> User-Agent: Mutt/1.5.22 (2013-10-16) X-Source-IP: acsinet21.oracle.com [141.146.126.237] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2499 Lines: 69 On Tue, Feb 24, 2015 at 11:37:04AM +0100, Borislav Petkov wrote: > From: Borislav Petkov > > ... of microcode patches instead of handing in a pointer which is used > for I/O in an otherwise void function. > > Signed-off-by: Borislav Petkov > --- > arch/x86/kernel/cpu/microcode/intel_early.c | 29 ++++++++++++++--------------- > 1 file changed, 14 insertions(+), 15 deletions(-) > > diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c > index ffeac5d62eca..ee74e7726c33 100644 > --- a/arch/x86/kernel/cpu/microcode/intel_early.c > +++ b/arch/x86/kernel/cpu/microcode/intel_early.c > @@ -264,17 +264,18 @@ err: > * - or if it is a newly discovered microcode patch. > * > * The microcode patch should have matching model with CPU. > + * > + * Returns: The updated number @num_saved of saved microcode patches. > */ > -static void _save_mc(struct microcode_intel **mc_saved, u8 *ucode_ptr, > - unsigned int *mc_saved_count_p) > +static unsigned int _save_mc(struct microcode_intel **mc_saved, > + u8 *ucode_ptr, unsigned int num_saved) > { > - int i; > - int found = 0; > - unsigned int mc_saved_count = *mc_saved_count_p; > struct microcode_header_intel *mc_header; > + int found = 0, i; > > mc_header = (struct microcode_header_intel *)ucode_ptr; > - for (i = 0; i < mc_saved_count; i++) { > + > + for (i = 0; i < num_saved; i++) { Minor comment: since num_saved is unsigned, I think it would be better to just use an unsigned int for `i` as well. > unsigned int sig, pf; > unsigned int new_rev; > struct microcode_header_intel *mc_saved_header = > @@ -291,21 +292,20 @@ static void _save_mc(struct microcode_intel **mc_saved, u8 *ucode_ptr, > * Replace the older one with this newer > * one. > */ > - mc_saved[i] = > - (struct microcode_intel *)ucode_ptr; > + mc_saved[i] = (struct microcode_intel *)ucode_ptr; > break; > } > } > } > - if (i >= mc_saved_count && !found) > + > + if (i >= num_saved && !found) While at it, I could not find that `i` would ever be bigger than `num_saved` so maybe you can just test for equality instead? It just makes it clearer what the code does. Quentin -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/