From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751055AbbEBAO2 (ORCPT ); Fri, 1 May 2015 20:14:28 -0400 Received: from mail-qc0-f171.google.com ([209.85.216.171]:33142 "EHLO mail-qc0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750746AbbEBAO0 (ORCPT ); Fri, 1 May 2015 20:14:26 -0400 Date: Fri, 1 May 2015 20:14:23 -0400 (EDT) From: Nicolas Pitre To: John Stultz cc: linux-kernel@vger.kernel.org, Thomas Gleixner , Josh Boyer , One Thousand Gnomes Subject: Re: [PATCH] ktime: Fix ktime_divns to do signed division In-Reply-To: <1430520085-24535-1-git-send-email-john.stultz@linaro.org> Message-ID: References: <1430520085-24535-1-git-send-email-john.stultz@linaro.org> User-Agent: Alpine 2.11 (LFD 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 May 2015, John Stultz wrote: > static inline u64 ktime_divns(const ktime_t kt, s64 div) > { > if (__builtin_constant_p(div) && !(div >> 32)) { > - u64 ns = kt.tv64; > + s64 ns = kt.tv64; > + int neg = 0; > + > + if (ns < 0) { > + neg = 1; > + ns = -ns; > + } Minor comment: you could save some realestate with: s64 ns = kt.tv64; bool neg = (ns < 0); if (neg) ns = -ns; Nicolas