From 446482efaa3d266266e2a143492a3ec0523622bd Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 28 Nov 2010 09:41:17 -0800 Subject: [PATCH] Convert cvt code to use XNFasprintf() Requires linking xprintf.c into standalone cvt utility Signed-off-by: Alan Coopersmith Reviewed-by: Mikhail Gusarov Reviewed-by: Julien Cristau --- hw/xfree86/modes/xf86cvt.c | 10 +--------- hw/xfree86/utils/cvt/Makefile.am | 5 ++++- hw/xfree86/utils/cvt/cvt.c | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/hw/xfree86/modes/xf86cvt.c b/hw/xfree86/modes/xf86cvt.c index 1da5fe50b..244f3b9a3 100644 --- a/hw/xfree86/modes/xf86cvt.c +++ b/hw/xfree86/modes/xf86cvt.c @@ -279,15 +279,7 @@ xf86CVTMode(int HDisplay, int VDisplay, float VRefresh, Bool Reduced, if (Interlaced) Mode->VTotal *= 2; - { - char Name[256]; - Name[0] = 0; - - snprintf(Name, 256, "%dx%d", HDisplay, VDisplay); - - Mode->name = xnfalloc(strlen(Name) + 1); - memcpy(Mode->name, Name, strlen(Name) + 1); - } + XNFasprintf(&Mode->name, "%dx%d", HDisplay, VDisplay); if (Reduced) Mode->Flags |= V_PHSYNC | V_NVSYNC; diff --git a/hw/xfree86/utils/cvt/Makefile.am b/hw/xfree86/utils/cvt/Makefile.am index 065868257..ba02145b7 100644 --- a/hw/xfree86/utils/cvt/Makefile.am +++ b/hw/xfree86/utils/cvt/Makefile.am @@ -27,7 +27,10 @@ INCLUDES = $(XORG_INCS) \ -I$(top_srcdir)/hw/xfree86/parser # gah -cvt_SOURCES = cvt.c $(top_srcdir)/hw/xfree86/modes/xf86cvt.c +cvt_SOURCES = cvt.c \ + $(top_srcdir)/hw/xfree86/modes/xf86cvt.c \ + $(top_srcdir)/os/xprintf.c + cvt_CFLAGS = $(DIX_CFLAGS) $(XORG_CFLAGS) man1_MANS = cvt.man diff --git a/hw/xfree86/utils/cvt/cvt.c b/hw/xfree86/utils/cvt/cvt.c index cf0a479f2..fff500b43 100644 --- a/hw/xfree86/utils/cvt/cvt.c +++ b/hw/xfree86/utils/cvt/cvt.c @@ -25,6 +25,24 @@ #include "xf86.h" +/* Error implementation used by the server code we built in */ +void +Error(const char *str) +{ + perror(str); +} + +/* FatalError implementation used by the server code we built in */ +void +FatalError(const char *f, ...) +{ + va_list args; + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); + exit(1); +} + /* xnfalloc implementation used by the server code we built in */ pointer XNFalloc(unsigned long n)