From: Ran Benita Date: Mon, 7 May 2012 11:44:30 +0000 (+0300) Subject: Don't use typeof X-Git-Tag: xkbcommon-0.2.0~614 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5eb0a70e61528adba4f14fe1c7e058cc01378c4c;p=platform%2Fupstream%2Flibxkbcommon.git Don't use typeof clang complains with the xorg-macros warning flags: src/context.c:58:36: error: extension used [-Werror,-pedantic,-Wlanguage-extension-token] typeof(new_paths)); This was not entirely correct, too. So bring back the casts to the results of the allocation macros; might as well make them a bit more type safe. Signed-off-by: Ran Benita --- diff --git a/src/context.c b/src/context.c index 9acb416..12aeed4 100644 --- a/src/context.c +++ b/src/context.c @@ -55,7 +55,7 @@ xkb_context_include_path_append(struct xkb_context *context, const char *path) new_paths = uTypedRecalloc(context->include_paths, context->size_include_paths, new_size, - typeof(new_paths)); + char *); if (!new_paths) return 0; context->include_paths = new_paths; diff --git a/src/utils.h b/src/utils.h index 2041134..3bb6a73 100644 --- a/src/utils.h +++ b/src/utils.h @@ -44,10 +44,10 @@ recalloc(void *ptr, size_t old_size, size_t new_size); */ #define UNCONSTIFY(const_ptr) ((void *)(uintptr_t)(const_ptr)) -#define uTypedAlloc(t) malloc(sizeof(t)) -#define uTypedCalloc(n, t) calloc((n), sizeof(t)) -#define uTypedRealloc(pO, n, t) realloc((pO), (n) * sizeof(t)) -#define uTypedRecalloc(pO, o, n, t) recalloc((pO), (o) * sizeof(t), (n) * sizeof(t)) +#define uTypedAlloc(t) ((t*)malloc(sizeof(t))) +#define uTypedCalloc(n, t) ((t*)calloc((n), sizeof(t))) +#define uTypedRealloc(pO, n, t) ((t*)realloc((pO), (n) * sizeof(t))) +#define uTypedRecalloc(pO, o, n, t) ((t*)recalloc((pO), (o) * sizeof(t), (n) * sizeof(t))) #define uDupString(s) ((s) ? strdup(s) : NULL) #define uStringText(s) ((s) == NULL ? "" : (s))