[systemd-devel] [PATCH rebased] Use strlen even for constant strings

Josh Triplett josh at joshtriplett.org
Sun Mar 16 13:05:25 PDT 2014


On Sun, Mar 16, 2014 at 02:56:10PM +0100, Zbigniew Jędrzejewski-Szmek wrote:
> On Sat, Mar 15, 2014 at 11:40:07AM -0700, Josh Triplett wrote:
> > GCC optimizes strlen("string constant") to a constant, even with -O0.
> > Thus, replace patterns like sizeof("string constant")-1 with
> > strlen("string constant") where possible, for clarity.  In particular,
> > for expressions intended to add up the lengths of components going into
> > a string, this often makes it clearer that the expression counts the
> > trailing '\0' exactly once, by putting the +1 for the '\0' at the end of
> > the expression, rather than hidden in a sizeof in the middle of the
> > expression.
> Applied, thanks.
> 
> > On Sat, Mar 15, 2014 at 05:37:49AM +0100, Zbigniew Jędrzejewski-Szmek wrote:
> > > strlen() is indeed much nicer. Unfortunately it stopped applying cleanly...
> > > Could you rebase this?
> > 
> > Done; git rebased it automatically with no conflicts.  (am -3 might work
> > in the future for patches that trivially rebase.)
> I tried that, but for some reason it didn't seem to work. Maybe
> your patch was missing the headers necessayr for -3?

Full commits have all those headers (the "index" lines with partial
hashes on them), but possibly I'm overestimating the capabilities of -3.
In any case, git rebase automatically did the three-way merge.

- Josh Triplett


More information about the systemd-devel mailing list