On Mon, 2014-12-08 at 09:49 +0100, Jiri Slaby wrote:
> On 12/07/2014, 08:20 PM, Julia Lawall wrote:
> > Replace the last argument of serial_paranoia_check by the actual function
> > name.
[]
> > diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
[]
> > @@ -931,7 +931,7 @@ static void rs_send_xchar(struct tty_struct *tty, char 
> > ch)
> >     struct serial_state *info = tty->driver_data;
> >          unsigned long flags;
> >  
> > -   if (serial_paranoia_check(info, tty->name, "rs_send_char"))
> > +   if (serial_paranoia_check(info, tty->name, "rs_send_xchar"))
> 
> I wonder, why not to use __func__ here too?

Nearly identical functions are used in amiserial and cyclades.
Disabled in amiserial, enabled in cyclades.

It might be better to add it to some file like
drivers/tty/debug_utils.h

It'd probably be better to change:

static inline int serial_paranoia_check(struct serial_state *info,
                                        char *name, const char *routine)
{
#ifdef SERIAL_PARANOIA_CHECK
        static const char *badmagic =
                "Warning: bad magic number for serial struct (%s) in %s\n";
        static const char *badinfo =
                "Warning: null async_struct for (%s) in %s\n";

        if (!info) {
                printk(badinfo, name, routine);
                return 1;
        }
        if (info->magic != SERIAL_MAGIC) {
                printk(badmagic, name, routine);
                return 1;
        }
#endif
        return 0;
}

to something like:

static inline int serial_paranoia_check(struct serial_state *info, char *name)
{
#ifdef SERIAL_PARANOIA_CHECK
        if (!info) {
                pr_warn("async_struct for (%s) is NULL in %pf\n",
                        name, __builtin_return_address(0));
                return 1;
        }
        if (info->magic != SERIAL_MAGIC) {
                pr_warn("serial struct (%s) has bad magic number in %pf\n",
                        name, __builtin_return_address(0));
                return 1;
        }
#endif
        return 0;
}

and remove all the function names from the callers.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to