net/libsmi: avoid printf %n

Bizarrely, that code block starts with a comment that Microsoft has
disabled %n, then adds an Microsoft-approved workaround.  I've left
that in place, even though it is entirely useless with the simple
fix below.  The value is only used to format the field width of
subsequent output, so I don't see a need to handle the error case.

OK?

Index: Makefile
===================================================================
RCS file: /cvs/ports/net/libsmi/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- Makefile    12 Jul 2019 20:48:31 -0000      1.8
+++ Makefile    12 Sep 2021 17:01:38 -0000
@@ -5,7 +5,7 @@ COMMENT=        library/tools (incl smilint) to
 SHARED_LIBS +=  smi                  0.0      # 2.27
 
 DISTNAME=      libsmi-0.4.8
-REVISION=      1
+REVISION=      2
 CATEGORIES=    net
 
 HOMEPAGE=      http://www.ibr.cs.tu-bs.de/projects/libsmi/
Index: patches/patch-tools_smidump_c
===================================================================
RCS file: patches/patch-tools_smidump_c
diff -N patches/patch-tools_smidump_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-tools_smidump_c       12 Sep 2021 17:01:38 -0000
@@ -0,0 +1,19 @@
+$OpenBSD$
+
+Index: tools/smidump.c
+--- tools/smidump.c.orig
++++ tools/smidump.c
+@@ -233,11 +233,10 @@ static void usage()
+           printf_state=_set_printf_count_output(1);
+     #endif
+ #endif
+-          fprintf(stderr, "  --%s-%s%s%s%n",
++          n = fprintf(stderr, "  --%s-%s%s%s",
+                   driver->name, driver->opt[i].name,
+                   value ? "=" : "",
+-                  value ? value : "",
+-                  &n);
++                  value ? value : "");
+ #ifdef _MSC_VER
+     #if _MSC_VER >= 1400
+           (void)_set_printf_count_output(printf_state);
-- 
Christian "naddy" Weisgerber                          na...@mips.inka.de

Reply via email to