[Fontconfig-bugs] [Bug 39914] Please tag the cache directory with CACHEDIR.TAG

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Mar 21 10:51:07 PDT 2012


https://bugs.freedesktop.org/show_bug.cgi?id=39914

--- Comment #14 from Josh Triplett <josh at freedesktop.org> 2012-03-21 10:51:07 PDT ---
(In reply to comment #13)
> First:
> 
> + static const FcChar8 cache_tag_contents[] =
> + "Signature: 8a477f597d28d172789f06886806bc55\n"
> + "# This file is a cache directory tag created by fontconfig.\n"
> + "# For information about cache directory tags, see:\n"
> + "# http://www.brynosaurus.com/cachedir/\n";
> + static size_t cache_tag_contents_size = 0;
> + FcBool ret = FcTrue;
> +
> + if (cache_tag_contents_size == 0)
> + cache_tag_contents_size = strlen((char *)cache_tag_contents);
> 
> You can simply use "sizeof (cache_tag_contents)".  No need for runtime
> strlen().

If you want to use sizeof, you'd need sizeof(cache_tag_contents)-1, since
sizeof counts the trailing '\0'.  More importantly, though, compilers such as
GCC know how to optimize strlen(constant_string) to a constant.

> + write(fd, cache_tag_contents, cache_tag_contents_size);
> 
> write() can fail with -EINTR.  Just use stdio or something.

True.

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


More information about the Fontconfig-bugs mailing list