summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-01-29 11:41:41 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-01-29 11:56:47 -0800
commit0b7c07a1667c1f7e692b7694d374f27d46c3c923 (patch)
tree28287b2cf88f85c1b314d23b46bdf8008340686d
parenta02099a6869064c8b8c04a91acf5ece8568c7389 (diff)
Refactor invalid depth error reporting to allow printf format checking
Clears gcc warnings: x2jet.c: In function `validate_visual': x2jet.c:1053: warning: format not a string literal, argument types not checked x2jet.c:1055: warning: format not a string literal, argument types not checked x2jet.c:1057: warning: format not a string literal, argument types not checked x2jet.c:1059: warning: format not a string literal, argument types not checked x2jet.c:1064: warning: format not a string literal, argument types not checked Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--x2jet.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/x2jet.c b/x2jet.c
index b5eabcc..2811f0f 100644
--- a/x2jet.c
+++ b/x2jet.c
@@ -1041,27 +1041,35 @@ void download_colors (
}
+static _X_INLINE _X_NORETURN
+void invalid_depth_for_visual(int depth, const char *name)
+{
+ fatal_err(catgets(nlmsg_fd,NL_SETN,25,
+ "%d bit deep %s bitmap not supported.\n"),
+ depth, name);
+}
+
static
void validate_visual(void)
{
int depth = xwd_header.pixmap_depth;
- char *errmsg = catgets(nlmsg_fd,NL_SETN,25,
- "%d bit deep %s bitmap not supported.\n");
switch (xwd_header.visual_class) {
case GrayScale:
- if (depth > 8) fatal_err(errmsg, depth, "GrayScale"); break;
+ if (depth > 8) invalid_depth_for_visual(depth, "GrayScale"); break;
case StaticGray:
- if (depth > 8) fatal_err(errmsg, depth, "StaticGray"); break;
+ if (depth > 8) invalid_depth_for_visual(depth, "StaticGray"); break;
case PseudoColor:
- if (depth > 8) fatal_err(errmsg, depth, "PseudoColor"); break;
+ if (depth > 8) invalid_depth_for_visual(depth, "PseudoColor"); break;
case StaticColor:
- if (depth > 8) fatal_err(errmsg, depth, "StaticColor"); break;
+ if (depth > 8) invalid_depth_for_visual(depth, "StaticColor"); break;
case DirectColor:
+ if (depth != 12 && depth != 24)
+ invalid_depth_for_visual(depth, "DirectColor");
+ break;
case TrueColor:
if (depth != 12 && depth != 24)
- fatal_err(errmsg, depth, (xwd_header.visual_class == DirectColor)
- ? "DirectColor" : "TrueColor");
+ invalid_depth_for_visual(depth, "TrueColor");
break;
default:
fatal_err((catgets(nlmsg_fd,NL_SETN,26,