Re: [PATCH 2/2] Replace literal STRLEN_ #defines in refs.h with compiler evaluated expressions

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

 



Andy Parkins <andyparkins@xxxxxxxxx> writes:

> Bill Lear pointed out that the following:
>
>  #define PATH_REMOTES             "remotes/"
>  #define STRLEN_PATH_REMOTES      8
>
> Could be replaced by the less error-prone
>
>  #define PATH_REMOTES "remotes/"
>  #define LIT_STRLEN(S) ((sizeof(S) / sizeof(S[0])) -1)
>  #define STRLEN_PATH_REMOTES LIT_STRLEN(PATH_REMOTES)
>
> which is what this patch does.

I do not think the above is wrong per se, but doesn't a good
compiler optimize

	#define PATH_REMOTES	"remotes/"
	#define STRLEN_PATH_REMOTES strlen(PATH_REMOTES)

	... and much later in some *.c file that includes the
	... above and <string.h>

        foo = strlen(PATH_REMOTES)

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

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux