Re: [PATCH 00/12] Hard coded string length cleanup

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

 



On Fri, Dec 20, 2013 at 6:32 AM, René Scharfe <l.s.r@xxxxxx> wrote:
> Seeing that skip_prefix_defval is mostly used in the form
> skip_prefix_defval(foo, prefix, foo) I wonder if it makes sense to
> first change skip_prefix to return the full string instead of NULL
> if the prefix is not matched.  Would the resulting function cover
> most use cases?  And would it still be easily usable?

That was skip_prefix_gently() that I forgot to replace in a commit
message, before I turned it into _defval variant. The reason for
_defval is it could be use to chain expression together without adding
temporary variables, e.g.

-       if (starts_with(line->buf, ">From") && isspace(line->buf[5])) {
+       if (isspace(*skip_prefix_defval(line->buf, ">From", "NOSPACE"))) {

Without _defval, one would need to do if ((p = skip_prefix(..)) &&
isspace(*p)). I'm not entirely sure this is a good thing though as it
could make it a bit harder to read.
-- 
Duy
--
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]