Re: [PATCH 1/4] Clean up my_basename()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/21/09, Andreas Robinson <andr345@xxxxxxxxx> wrote:
> Combines five implementations found in depmod.c, insmod.c, modprobe.c and
> util.c.

Great, well done for picking up the open-coded versions.

> The new version is implemented as a macro.
>
> --- a/util.h
> +++ b/util.h
> @@ -12,5 +12,6 @@ const char *next_string(const char *string, unsigned long
> *secsize);
>
>  #define streq(a,b) (strcmp((a),(b)) == 0)
>  #define strstarts(a,start) (strncmp((a),(start), strlen(start)) == 0)
> +#define my_basename(path) ((strrchr((path), '/') ?: (path) - 1) + 1)

Ew.  This is the 21st century, aren't we allowed to use inline functions?

I.e. define it as "static inline" in the header file.  If we're
worried about inline not being supported, autoconf seems to have it
covered with AC_C_INLINE [1].

[1] http://www.delorie.com/gnu/docs/autoconf/autoconf_64.html

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux