[PATCH 2/2] Use const more often

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

 



This eliminates several warnings about improper const usage as well as
making it more prevalent in the implementation.

Signed-off-by: Keith Packard <keithp@xxxxxxxxxx>
---
 fc-lang/fc-lang.c |    6 +++---
 src/fccache.c     |    2 +-
 src/fccfg.c       |    8 ++++----
 src/fcint.h       |   20 ++++++++++----------
 src/fcxml.c       |   14 +++++++-------
 5 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c
index 51717f9..d29dc10 100644
--- a/fc-lang/fc-lang.c
+++ b/fc-lang/fc-lang.c
@@ -136,7 +136,7 @@ static FcCharSet *
 scan (FILE *f, char *file, FcCharSetFreezer *freezer)
 {
     FcCharSet	    *c = 0;
-    FcCharSet	    *n;
+    const FcCharSet *n;
     FcBool	    del;
     int		    start, end, ucs4;
     char	    buf[1024];
@@ -164,7 +164,7 @@ scan (FILE *f, char *file, FcCharSetFreezer *freezer)
 		c = FcCharSetCreate ();
 	    if (!FcCharSetMerge (c, n, NULL))
 		fatal (file, lineno, "out of memory");
-	    FcCharSetDestroy (n);
+	    FcCharSetDestroy ((FcCharSet *) n);
 	    continue;
 	}
 	del = FcFalse;
@@ -246,7 +246,7 @@ typedef struct _Entry {
 
 static int compare (const void *a, const void *b)
 {
-    const Entry *as = a, *bs = b;
+    const Entry const *as = a, *bs = b;
     return FcStrCmpIgnoreCase ((const FcChar8 *) as->file, (const FcChar8 *) bs->file);
 }
 
diff --git a/src/fccache.c b/src/fccache.c
index a72dbb6..5ed7edf 100644
--- a/src/fccache.c
+++ b/src/fccache.c
@@ -1000,7 +1000,7 @@ FcDirCacheWrite (FcCache *cache, FcConfig *config)
      */
     if (cache->size < FC_CACHE_MIN_MMAP &&
 	(skip = FcCacheFindByAddr (cache)) &&
-	FcStat (cache_hashed, &cache_stat))
+	FcStat ((const char *) cache_hashed, &cache_stat))
     {
 	skip->cache_dev = cache_stat.st_dev;
 	skip->cache_ino = cache_stat.st_ino;
diff --git a/src/fccfg.c b/src/fccfg.c
index 9395f74..dcc0097 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -866,7 +866,7 @@ FcConfigCompareValue (const FcValue	*left_o,
 #define FcDoubleTrunc(d)	((d) >= 0 ? _FcDoubleFloor (d) : -_FcDoubleFloor (-(d)))
 
 static FcValue
-FcConfigEvaluate (FcPattern *p, FcExpr *e)
+FcConfigEvaluate (FcPattern *p, const FcExpr *e)
 {
     FcValue	v, vl, vr;
     FcResult	r;
@@ -913,7 +913,7 @@ FcConfigEvaluate (FcPattern *p, FcExpr *e)
 	v = FcValueSave (v);
 	break;
     case FcOpConst:
-	if (FcNameConstant (e->u.constant, &v.u.i))
+	if (FcNameConstant ((FcChar8 *) e->u.constant, &v.u.i))
 	    v.type = FcTypeInteger;
 	else
 	    v.type = FcTypeVoid;
@@ -1179,7 +1179,7 @@ FcConfigMatchValueList (FcPattern	*p,
 			FcValueList	*values)
 {
     FcValueList	    *ret = 0;
-    FcExpr	    *e = t->expr;
+    const FcExpr    *e = t->expr;
     FcValue	    value;
     FcValueList	    *v;
 
@@ -1220,7 +1220,7 @@ FcConfigMatchValueList (FcPattern	*p,
 }
 
 static FcValueList *
-FcConfigValues (FcPattern *p, FcExpr *e, FcValueBinding binding)
+FcConfigValues (FcPattern *p, const FcExpr *e, FcValueBinding binding)
 {
     FcValueList	*l;
 
diff --git a/src/fcint.h b/src/fcint.h
index 8179195..fd327de 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -237,17 +237,17 @@ typedef enum _FcOp {
 typedef struct _FcExpr {
     FcOp   op;
     union {
-	int	    ival;
-	double	    dval;
-	const FcChar8	    *sval;
-	FcMatrix    *mval;
-	FcBool	    bval;
-	FcCharSet   *cval;
-	FcLangSet   *lval;
-	FcObject    object;
-	const FcChar8	    *constant;
+	int	    	ival;
+	double	    	dval;
+	const FcChar8	*sval;
+	const FcMatrix  *mval;
+	FcBool	    	bval;
+	const FcCharSet *cval;
+	FcLangSet   	*lval;
+	FcObject    	object;
+	const FcChar8	*constant;
 	struct {
-	    struct _FcExpr *left, *right;
+	    const struct _FcExpr *left, *right;
 	} tree;
     } u;
 } FcExpr;
diff --git a/src/fcxml.c b/src/fcxml.c
index ff30b7b..794210b 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -61,7 +61,7 @@
 #endif
 
 static void
-FcExprDestroy (FcExpr *e);
+FcExprDestroy (const FcExpr *e);
 
 void
 FcTestDestroy (FcTest *test)
@@ -195,7 +195,7 @@ FcExprCreateOp (FcConfig *config, FcExpr *left, FcOp op, FcExpr *right)
 }
 
 static void
-FcExprDestroy (FcExpr *e)
+FcExprDestroy (const FcExpr *e)
 {
     if (!e)
 	return;
@@ -207,12 +207,12 @@ FcExprDestroy (FcExpr *e)
     case FcOpString:
 	break;
     case FcOpMatrix:
-	FcMatrixFree (e->u.mval);
+	FcMatrixFree ((FcMatrix *) e->u.mval);
 	break;
     case FcOpRange:
 	break;
     case FcOpCharSet:
-	FcCharSetDestroy (e->u.cval);
+	FcCharSetDestroy ((FcCharSet *) e->u.cval);
 	break;
     case FcOpLangSet:
 	FcLangSetDestroy (e->u.lval);
@@ -261,7 +261,7 @@ FcExprDestroy (FcExpr *e)
 	break;
     }
 
-    e->op = FcOpNil;
+    ((FcExpr *) e)->op = FcOpNil;
 }
 
 void
@@ -564,7 +564,7 @@ FcTypecheckValue (FcConfigParse *parse, FcType value, FcType type)
 }
 
 static void
-FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type)
+FcTypecheckExpr (FcConfigParse *parse, const FcExpr *expr, FcType type)
 {
     const FcObjectType	*o;
     const FcConstant	*c;
@@ -601,7 +601,7 @@ FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type)
 	    FcTypecheckValue (parse, o->type, type);
 	break;
     case FcOpConst:
-	c = FcNameGetConstant (expr->u.constant);
+	c = FcNameGetConstant ((FcChar8 *) expr->u.constant);
 	if (c)
 	{
 	    o = FcNameGetObjectType (c->object);
-- 
1.7.10

_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig


[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux