[PATCH] Updated Legacy code in arm csb336

Joel Sherrill Joel.Sherrill at OARcorp.com
Tue Jul 9 12:34:13 UTC 2013

Chris Johns and I chatted about a similar situation with the use of some of the bspopts.h constants. Some are 0/1 and always defined which makes checking if it is defined bogus.

Personally I would move to the simple #if and define it to be 1. That way when 0 or defined, the code is correct.

Vipul Nayyar <nayyar_vipul at yahoo.com> wrote:


Seems like a valid point to me, that you got there.

Sebastian, What do you suggest ? Simply remove the 1 from '#define USE_INTERRUPTS 1' or change #if defined() to simply #if  ?

Vipul Nayyar

From: Peter Dufault <dufault at hda.com>
To: Vipul Nayyar <nayyar_vipul at yahoo.com>
Cc: "rtems-devel at rtems.org" <rtems-devel at rtems.org>
Sent: Tuesday, 9 July 2013 5:22 PM
Subject: Re: [PATCH] Updated Legacy code in arm csb336

On Jul 8, 2013, at 09:43 , Vipul Nayyar <nayyar_vipul at yahoo.com<mailto:nayyar_vipul at yahoo.com>> wrote:

> /* Define this to use interrupt driver UART driver */
> #define USE_INTERRUPTS 1

( . . . )

> #if defined(USE_INTERRUPTS)

Personal observation:

I don't like using "#define USE_INTERRUPTS 1" in conjunction with "#if defined(USE_INTERRUPTS)".  Someone not too careful will change it to "#define USE_INTERRUPTS 0" and not understand why it is still being used.

I either use "#define USE_INTERRUPTS" (I know it is defined to be 1) or "#define USE_INTERRUPTS 1" (or 0) in conjunction with "#if USE_INTERRUPTS".  I use the second idiom in my own code, it also protects against typos such as "#if defined(USE_INTERUPTS)"

Peter Dufault
HD Associates, Inc.      Software and System Engineering

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20130709/6c41c83b/attachment.html>

More information about the devel mailing list