From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971171AbdEZKbV (ORCPT ); Fri, 26 May 2017 06:31:21 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:40802 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966403AbdEZKbT (ORCPT ); Fri, 26 May 2017 06:31:19 -0400 Date: Fri, 26 May 2017 12:31:15 +0200 (CEST) From: Thomas Gleixner To: Mariusz Skamra cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH] ktime: Simplify ktime_* comparison functions In-Reply-To: <1495793358-4593-1-git-send-email-mariuszx.skamra@intel.com> Message-ID: References: <1495793358-4593-1-git-send-email-mariuszx.skamra@intel.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) 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, 26 May 2017, Mariusz Skamra wrote: > -static inline int ktime_compare(const ktime_t cmp1, const ktime_t cmp2) > -{ > - if (cmp1 < cmp2) > - return -1; > - if (cmp1 > cmp2) > - return 1; > - return 0; > -} > +#define ktime_compare(cmp1, cmp2) ktime_sub(cmp1, cmp2) What's wrong with modifying the inline itself? > -static inline bool ktime_after(const ktime_t cmp1, const ktime_t cmp2) > -{ > - return ktime_compare(cmp1, cmp2) > 0; > -} > +#define ktime_after(cmp1, cmp2) (ktime_compare(cmp1, cmp2) > 0) > -static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2) > -{ > - return ktime_compare(cmp1, cmp2) < 0; > -} > +#define ktime_before(cmp1, cmp2) (ktime_compare(cmp1, cmp2) < 0) Sorry, but those two are just crap. That inline compiles to exactly the same code as the macro. If not, yell at your compiler people. Thanks, tglx