lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [PATCH] Win32 port - snprintf


From: Alon Bar-Lev
Subject: [lwip-devel] [PATCH] Win32 port - snprintf
Date: Sat, 21 Mar 2009 08:16:51 +0200
User-agent: KMail/1.11.1 (Linux/2.6.28-gentoo-r4; KDE/4.2.1; i686; ; )

Hello,

It took me a while to understand why snprintf is not working
correctly in my project, it always truncated the last character.

Then I found that the lwip win32 port has a printf override!

I don't understand why it is needed at all as all MS compilers
since MSVC6 has this function.

Also:
http://cvs.savannah.gnu.org/viewvc/contrib/ports/win32/include/arch/cc.h?root=lwip&view=diff&r1=1.2&r2=1.3

I suggest to drop this, or #ifdef only when needed.

Anyway, the vsprintf returns the actual string length
without the trailing zero in any platform... So it needs to be fixed.

And there is _vsnprintf... So no need to ignore the size.

Thanks!

---

--- a/contrib/ports/win32/sio.c 2009-03-21 08:02:22.000000000 +0200
+++ b/contrib/ports/win32/sio.c 2009-03-21 08:02:06.000000000 +0200
@@ -140,7 +140,7 @@ int snprintf( char *buffer, size_t count
 
   va_start  ( argList, format);
   len=vsprintf( buffer, format, argList);
-  buffer[len-1]='\0';
+  buffer[len]='\0';
   va_end    ( argList);
   return len;
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]