[libfontenc PATCH] make FontEncDirectory return a const string

Alan Coopersmith alan.coopersmith at oracle.com
Sun Jul 26 11:14:45 PDT 2015


While it's nominally exported, I see the only result in codesearch.debian.net
for calling it is from the call in FontEncReallyLoad, so it's safe to change.

Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

	-alan-

On 07/26/15 10:21 AM, Julien Cristau wrote:
> Its comment already said "This string is static and should not be
> modified".
>
> encparse.c: In function 'FontEncDirectory':
> encparse.c:844:17: warning: assignment discards 'const' qualifier from pointer target type
>               dir = FONT_ENCODINGS_DIRECTORY;
>                   ^
>
> Signed-off-by: Julien Cristau <jcristau at debian.org>
> ---
>   include/X11/fonts/fontenc.h | 2 +-
>   src/encparse.c              | 8 ++++----
>   2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/include/X11/fonts/fontenc.h b/include/X11/fonts/fontenc.h
> index 709f97f..6c35c93 100644
> --- a/include/X11/fonts/fontenc.h
> +++ b/include/X11/fonts/fontenc.h
> @@ -109,7 +109,7 @@ char *FontEncName(unsigned, FontMapPtr);
>
>   /* Return a pointer to the name of the system encodings directory. */
>   /* This string is static and should not be modified. */
> -char *FontEncDirectory(void);
> +const char *FontEncDirectory(void);
>
>   /* Identify an encoding file.  If fileName doesn't exist, or is not an
>      encoding file, return NULL, otherwise returns a NULL-terminated
> diff --git a/src/encparse.c b/src/encparse.c
> index f47454a..548110e 100644
> --- a/src/encparse.c
> +++ b/src/encparse.c
> @@ -827,13 +827,13 @@ parseEncodingFile(FontFilePtr f, int headerOnly)
>       return NULL;
>   }
>
> -char *
> +const char *
>   FontEncDirectory(void)
>   {
> -    static char *dir = NULL;
> +    static const char *dir = NULL;
>
>       if (dir == NULL) {
> -        char *c = getenv("FONT_ENCODINGS_DIRECTORY");
> +        const char *c = getenv("FONT_ENCODINGS_DIRECTORY");
>
>           if (c) {
>               dir = strdup(c);
> @@ -941,7 +941,7 @@ FontEncReallyLoad(const char *charset, const char *fontFileName)
>   {
>       FontEncPtr encoding;
>       char dir[MAXFONTFILENAMELEN], dirname[MAXFONTFILENAMELEN];
> -    char *d;
> +    const char *d;
>
>       if (fontFileName) {
>           parseFontFileName(fontFileName, dirname, dir);
>


-- 
	-Alan Coopersmith-              alan.coopersmith at oracle.com
	 Oracle Solaris Engineering - http://blogs.oracle.com/alanc


More information about the xorg-devel mailing list