Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752127AbcJKTBP (ORCPT ); Tue, 11 Oct 2016 15:01:15 -0400 Received: from pandora.armlinux.org.uk ([78.32.30.218]:53094 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751503AbcJKTAe (ORCPT ); Tue, 11 Oct 2016 15:00:34 -0400 Date: Tue, 11 Oct 2016 19:52:36 +0100 From: Russell King - ARM Linux To: Tyler Baicar Cc: christoffer.dall@linaro.org, marc.zyngier@arm.com, pbonzini@redhat.com, rkrcmar@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, lenb@kernel.org, matt@codeblueprint.co.uk, robert.moore@intel.com, lv.zheng@intel.com, mark.rutland@arm.com, james.morse@arm.com, akpm@linux-foundation.org, sandeepa.s.prabhu@gmail.com, shijie.huang@arm.com, paul.gortmaker@windriver.com, tomasz.nowicki@linaro.org, fu.wei@linaro.org, rostedt@goodmis.org, bristot@redhat.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Dkvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-efi@vger.kernel.org, devel@acpica.org, "Jonathan (Zhixiong) Zhang" , Richard Ruigrok , Naveen Kaje Subject: Re: [PATCH V3 02/10] ras: acpi/apei: cper: generic error data entry v3 per ACPI 6.1 Message-ID: <20161011185236.GC1041@n2100.armlinux.org.uk> References: <1475875882-2604-1-git-send-email-tbaicar@codeaurora.org> <1475875882-2604-3-git-send-email-tbaicar@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1475875882-2604-3-git-send-email-tbaicar@codeaurora.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2714 Lines: 78 On Fri, Oct 07, 2016 at 03:31:14PM -0600, Tyler Baicar wrote: > +static void cper_estatus_print_section_v300(const char *pfx, > + const struct acpi_hest_generic_data_v300 *gdata) > +{ > + __u8 hour, min, sec, day, mon, year, century, *timestamp; > + > + if (gdata->validation_bits & ACPI_HEST_GEN_VALID_TIMESTAMP) { > + timestamp = (__u8 *)&(gdata->time_stamp); > + memcpy(&sec, timestamp, 1); > + memcpy(&min, timestamp + 1, 1); > + memcpy(&hour, timestamp + 2, 1); > + memcpy(&day, timestamp + 4, 1); > + memcpy(&mon, timestamp + 5, 1); > + memcpy(&year, timestamp + 6, 1); > + memcpy(¢ury, timestamp + 7, 1); This is utterly silly. Why are you using memcpy() to access individual bytes of a u8 pointer? What's wrong with: sec = timestamp[0]; min = timestamp[1]; hour = timestamp[2]; day = timestamp[4]; mon = timestamp[5]; year = timestamp[6]; century = timestamp[7]; or even do the conversion here: sec = bcd2bin(timestamp[0]); ... etc ... > + printk("%stime: ", pfx); > + printk("%7s", 0x01 & *(timestamp + 3) ? "precise" : ""); > + printk(" %02d:%02d:%02d %02d%02d-%02d-%02d\n", > + bcd2bin(hour), bcd2bin(min), bcd2bin(sec), > + bcd2bin(century), bcd2bin(year), bcd2bin(mon), > + bcd2bin(day)); > + } It's also a good idea to (as much as possible) keep to single printk() statements - which makes the emission of the string more atomic wrt other CPUs and contexts. So, this should probably become (with the conversion being done at the assignment of sec etc): printk("%stime: %7s %02d:%02d:%02d %02d%02d-%02d-%02d\n", pfx, 0x01 & timestamp[3] ? "precise" : "", hour, min, sec, century, year, mon, day); which, IMHO, looks a lot nicer and doesn't risk some other printk() getting between each individual part of the line. > +} > + > static void cper_estatus_print_section( > - const char *pfx, const struct acpi_hest_generic_data *gdata, int sec_no) > + const char *pfx, struct acpi_hest_generic_data *gdata, int sec_no) > { > uuid_le *sec_type = (uuid_le *)gdata->section_type; > __u16 severity; > char newpfx[64]; > > + if ((gdata->revision >> 8) >= 0x03) > + cper_estatus_print_section_v300(pfx, > + (const struct acpi_hest_generic_data_v300 *)gdata); > + > severity = gdata->error_severity; > printk("%s""Error %d, type: %s\n", pfx, sec_no, > cper_severity_str(severity)); Not sure why you have the "" here - %sError works just as well and the "" is just obfuscation - the compiler will eliminate the double-double quote and merge the strings anyway. -- RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.