From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH 1/6] tools/libxl: Introduce min and max macros Date: Fri, 20 Feb 2015 11:08:14 +0000 Message-ID: <54E7159E.8090201@citrix.com> References: <1424277263-27745-1-git-send-email-andrew.cooper3@citrix.com> <1424277263-27745-2-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Frediano Ziglio Cc: Wei Liu , Ian Jackson , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org On 20/02/15 10:42, Frediano Ziglio wrote: > 2015-02-18 16:34 GMT+00:00 Andrew Cooper : >> diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h >> index 934465a..a2b6fb7 100644 >> --- a/tools/libxl/libxl_internal.h >> +++ b/tools/libxl/libxl_internal.h >> @@ -108,6 +108,22 @@ >> >> #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) >> >> +#define min(X, Y) ({ \ >> + const typeof (X) _x = (X); \ >> + const typeof (Y) _y = (Y); \ >> + (void) (&_x == &_y); \ >> + (_x < _y) ? _x : _y; }) >> +#define max(X, Y) ({ \ >> + const typeof (X) _x = (X); \ >> + const typeof (Y) _y = (Y); \ >> + (void) (&_x == &_y); \ >> + (_x > _y) ? _x : _y; }) >> + >> +#define min_t(type,x,y) \ >> + ({ type __x = (x); type __y = (y); __x < __y ? __x: __y; }) >> +#define max_t(type,x,y) \ >> + ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; }) >> + > Surely nobody will complain about these defines but according to > standard (ie https://www.securecoding.cert.org/confluence/display/seccode/DCL37-C.+Do+not+declare+or+define+a+reserved+identifier) > identifiers that start with double underscore are reserved. Here you > used _x, _y and __x, __y as it's a single patch make at least > coherent. I will adjust in v2. No point breaking the rules given that it is trivial to fix. ~Andrew