Skip to content

Commit

Permalink
Convert cvt code to use XNFasprintf()
Browse files Browse the repository at this point in the history
Requires linking xprintf.c into standalone cvt utility

Signed-off-by: Alan Coopersmith <[email protected]>
Reviewed-by: Mikhail Gusarov <[email protected]>
Reviewed-by: Julien Cristau <[email protected]>
  • Loading branch information
alanc committed Dec 7, 2010
1 parent d2c42b1 commit 446482e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
10 changes: 1 addition & 9 deletions hw/xfree86/modes/xf86cvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion hw/xfree86/utils/cvt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions hw/xfree86/utils/cvt/cvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 446482e

Please sign in to comment.