All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] Exception "try to delete an expanded token: {" and C macros
@ 2014-07-21 23:25 Riccardo Lucchese
  2014-07-22 16:17 ` Julia Lawall
  0 siblings, 1 reply; 3+ messages in thread
From: Riccardo Lucchese @ 2014-07-21 23:25 UTC (permalink / raw)
  To: cocci

Hello,

Running the command (semantic patch is attached)

$ spatch --sp-file macro-err.cocci --dir drivers/staging/octeon-usb/octeon-hcd.c

from the root dir of linux-next-20140721, yields the following error:

init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: drivers/staging/octeon-usb/octeon-hcd.c
Fatal error: exception Failure("drivers/staging/octeon-usb/octeon-hcd.c: 429: try to delete an expanded token: {")


The code around where the exception happens (--->) reads:

/* This macro spins on a field waiting for it to reach a value */
#define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\
--->    ({int result;                                                       \
        do {                                                                \
                uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \
                        octeon_get_clock_rate() / 1000000;                  \
                type c;                                                     \
                while (1) {                                                 \
                        c.u32 = __cvmx_usb_read_csr32(usb, address);        \
                        if (c.s.field op (value)) {                         \
                                result = 0;                                 \
                                break;                                      \
                        } else if (cvmx_get_cycle() > done) {               \
                                result = -1;                                \
                                break;                                      \
                        } else                                              \
                                cvmx_wait(100);                             \
                }                                                           \
        } while (0);                                                        \
        result; })


Should I change something in my invocation to deal with this macro ?

Thanks,
riccardo

-------------- next part --------------
@@
identifier func;
expression e;
identifier x;
statement S;
@@
func(...) {
<...
* if (<+... (x = e) ...+>) S
...>
}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Cocci] Exception "try to delete an expanded token: {" and C macros
  2014-07-21 23:25 [Cocci] Exception "try to delete an expanded token: {" and C macros Riccardo Lucchese
@ 2014-07-22 16:17 ` Julia Lawall
  2014-07-22 17:03   ` Riccardo Lucchese
  0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2014-07-22 16:17 UTC (permalink / raw)
  To: cocci



On Tue, 22 Jul 2014, Riccardo Lucchese wrote:

> Hello,
>
> Running the command (semantic patch is attached)
>
> $ spatch --sp-file macro-err.cocci --dir drivers/staging/octeon-usb/octeon-hcd.c
>
> from the root dir of linux-next-20140721, yields the following error:
>
> init_defs_builtins: /usr/local/share/coccinelle/standard.h
> HANDLING: drivers/staging/octeon-usb/octeon-hcd.c
> Fatal error: exception Failure("drivers/staging/octeon-usb/octeon-hcd.c: 429: try to delete an expanded token: {")
>
>
> The code around where the exception happens (--->) reads:
>
> /* This macro spins on a field waiting for it to reach a value */
> #define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\
> --->    ({int result;                                                       \
>         do {                                                                \
>                 uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \
>                         octeon_get_clock_rate() / 1000000;                  \
>                 type c;                                                     \
>                 while (1) {                                                 \
>                         c.u32 = __cvmx_usb_read_csr32(usb, address);        \
>                         if (c.s.field op (value)) {                         \
>                                 result = 0;                                 \
>                                 break;                                      \
>                         } else if (cvmx_get_cycle() > done) {               \
>                                 result = -1;                                \
>                                 break;                                      \
>                         } else                                              \
>                                 cvmx_wait(100);                             \
>                 }                                                           \
>         } while (0);                                                        \
>         result; })
>
>
> Should I change something in my invocation to deal with this macro ?

One solution is to add the following command-line argument:
--disable-multi-pass

Then it will not try to take macros into account on a parse failure.  But
there may be other macros whose definitions do need to be taken into
account to get parsing to succeed.

Another option is to extend standard.h with

#define CVMX_WAIT_FOR_FIELD32(a,b,c,d,e,f)

and then give the resulting file with the argument --macro-file-builtins.
That will make it use your standard.h definition before it tries the real
definition.

julia

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Cocci] Exception "try to delete an expanded token: {" and C macros
  2014-07-22 16:17 ` Julia Lawall
@ 2014-07-22 17:03   ` Riccardo Lucchese
  0 siblings, 0 replies; 3+ messages in thread
From: Riccardo Lucchese @ 2014-07-22 17:03 UTC (permalink / raw)
  To: cocci

On Tue, Jul 22, 2014 at 06:17:10PM +0200, Julia Lawall wrote:
> 
> 
> On Tue, 22 Jul 2014, Riccardo Lucchese wrote:
> 
> > Hello,
> >
> > Running the command (semantic patch is attached)
> >
> > $ spatch --sp-file macro-err.cocci --dir drivers/staging/octeon-usb/octeon-hcd.c
> >
> > from the root dir of linux-next-20140721, yields the following error:
> >
> > init_defs_builtins: /usr/local/share/coccinelle/standard.h
> > HANDLING: drivers/staging/octeon-usb/octeon-hcd.c
> > Fatal error: exception Failure("drivers/staging/octeon-usb/octeon-hcd.c: 429: try to delete an expanded token: {")
> >
> >
> > The code around where the exception happens (--->) reads:
> >
> > /* This macro spins on a field waiting for it to reach a value */
> > #define CVMX_WAIT_FOR_FIELD32(address, type, field, op, value, timeout_usec)\
> > --->    ({int result;                                                       \
> >         do {                                                                \
> >                 uint64_t done = cvmx_get_cycle() + (uint64_t)timeout_usec * \
> >                         octeon_get_clock_rate() / 1000000;                  \
> >                 type c;                                                     \
> >                 while (1) {                                                 \
> >                         c.u32 = __cvmx_usb_read_csr32(usb, address);        \
> >                         if (c.s.field op (value)) {                         \
> >                                 result = 0;                                 \
> >                                 break;                                      \
> >                         } else if (cvmx_get_cycle() > done) {               \
> >                                 result = -1;                                \
> >                                 break;                                      \
> >                         } else                                              \
> >                                 cvmx_wait(100);                             \
> >                 }                                                           \
> >         } while (0);                                                        \
> >         result; })
> >
> >
> > Should I change something in my invocation to deal with this macro ?
> 
> One solution is to add the following command-line argument:
> --disable-multi-pass
> 
> Then it will not try to take macros into account on a parse failure.  But
> there may be other macros whose definitions do need to be taken into
> account to get parsing to succeed.
> 
> Another option is to extend standard.h with
> 
> #define CVMX_WAIT_FOR_FIELD32(a,b,c,d,e,f)
> 
> and then give the resulting file with the argument --macro-file-builtins.
> That will make it use your standard.h definition before it tries the real
> definition.
> 
> julia

I see. Thanks !

riccardo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-07-22 17:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-21 23:25 [Cocci] Exception "try to delete an expanded token: {" and C macros Riccardo Lucchese
2014-07-22 16:17 ` Julia Lawall
2014-07-22 17:03   ` Riccardo Lucchese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.