From f6dedaee3012cbadab8cd2503bdd98ae1a11edac Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 26 Mar 2014 08:50:48 -0600 Subject: [PATCH] tools/astyle.sh: Formatting tool based on logic from Lorenz Meier --- ChangeLog | 2 ++ arch/arm/src/sam34/sam_udp.c | 1 + arch/arm/src/sama5/sam_udphs.c | 1 + tools/README.txt | 8 +++++++ tools/astyle.sh | 43 ++++++++++++++++++++++++++++++++++ tools/indent.sh | 2 +- 6 files changed, 56 insertions(+), 1 deletion(-) create mode 100755 tools/astyle.sh diff --git a/ChangeLog b/ChangeLog index fa6fdd153a..c603f00139 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7044,4 +7044,6 @@ the task that started in (other than knowing it as the parent). This allows me to remove so kludge logic to "deparent" the pthread on startup (2014-3-25). + * tools/astyle.sh: A code formatting tool from Lorenz Meier. This + tool should do a better job than the old tools/indent.sh tool. diff --git a/arch/arm/src/sam34/sam_udp.c b/arch/arm/src/sam34/sam_udp.c index 6cf8f5cc3f..acb0657e25 100644 --- a/arch/arm/src/sam34/sam_udp.c +++ b/arch/arm/src/sam34/sam_udp.c @@ -3082,6 +3082,7 @@ static int sam_ep_submit(struct usbdev_ep_s *ep, struct usbdev_req_s *req) epno = USB_EPNO(ep->eplog); req->result = -EINPROGRESS; req->xfrd = 0; + privreq->inflight = 0; flags = irqsave(); /* Handle IN (device-to-host) requests. NOTE: If the class device is diff --git a/arch/arm/src/sama5/sam_udphs.c b/arch/arm/src/sama5/sam_udphs.c index 8f324ac1a6..d71abc82c7 100644 --- a/arch/arm/src/sama5/sam_udphs.c +++ b/arch/arm/src/sama5/sam_udphs.c @@ -3575,6 +3575,7 @@ static int sam_ep_submit(struct usbdev_ep_s *ep, struct usbdev_req_s *req) epno = USB_EPNO(ep->eplog); req->result = -EINPROGRESS; req->xfrd = 0; + privreq->inflight = 0; flags = irqsave(); /* Handle IN (device-to-host) requests. NOTE: If the class device is diff --git a/tools/README.txt b/tools/README.txt index a1bf40b601..f0feff6610 100644 --- a/tools/README.txt +++ b/tools/README.txt @@ -12,6 +12,12 @@ README.txt This file! +astyle.sh +--------- + + A C formatting tool from Lorenz Meier. This is based on astyle and gets + very close to the NuttX coding style. + Config.mk --------- @@ -528,6 +534,8 @@ indent.sh to my coding NuttX coding style. It doesn't do a really good job, however (see the comments at the top of the indent.sh file). + See astyle.sh above. I suspect that it will do a better job. + zipme.sh -------- diff --git a/tools/astyle.sh b/tools/astyle.sh new file mode 100755 index 0000000000..9b5cc0c0ff --- /dev/null +++ b/tools/astyle.sh @@ -0,0 +1,43 @@ +#!/bin/sh +############################################################################ +# tools/astyle.sh +# +# Copyright (C) 2014 Gregory Nutt. All rights reserved. +# Author: Lorenz Meier +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +astyle \ + --style=gnu \ + --indent=spaces=2 \ + --indent-cases \ + --indent-switches \ + $* + diff --git a/tools/indent.sh b/tools/indent.sh index 4ebae9652f..866430e7e2 100755 --- a/tools/indent.sh +++ b/tools/indent.sh @@ -41,7 +41,7 @@ # - I usually align things vertically (like '=' in assignments), # - indent puts a bogus blank line at the top of the file, # - I don't like the way it handles nested conditional compilation intermixed with code. -# - I also indent brackets differently on structures than does not script. +# - I also indent brackets differently on structures than does this script. # # Constants