All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more
@ 2016-03-29 16:25 Sven Strickroth
  2016-03-29 16:43 ` Junio C Hamano
  2016-03-29 19:09 ` Sebastian Schuberth
  0 siblings, 2 replies; 7+ messages in thread
From: Sven Strickroth @ 2016-03-29 16:25 UTC (permalink / raw)
  To: Git List, Junio C Hamano, Sebastian Schuberth, blees

In MSVC2015 the behavior of vsnprintf was changed.
W/o this fix there is one character missing at the end.

Signed-off-by: Sven Strickroth <sven@cs-ware.de>
---
 compat/snprintf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/snprintf.c b/compat/snprintf.c
index 42ea1ac..0b11688 100644
--- a/compat/snprintf.c
+++ b/compat/snprintf.c
@@ -9,7 +9,7 @@
  * always have room for a trailing NUL byte.
  */
 #ifndef SNPRINTF_SIZE_CORR
-#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)
+#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)
 #define SNPRINTF_SIZE_CORR 1
 #else
 #define SNPRINTF_SIZE_CORR 0
-- 
2.7.4.windows.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more
  2016-03-29 16:25 [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more Sven Strickroth
@ 2016-03-29 16:43 ` Junio C Hamano
  2016-03-29 19:09 ` Sebastian Schuberth
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2016-03-29 16:43 UTC (permalink / raw)
  To: Sven Strickroth; +Cc: Git List, Sebastian Schuberth, blees

Sven Strickroth <sven@cs-ware.de> writes:

> In MSVC2015 the behavior of vsnprintf was changed.
> W/o this fix there is one character missing at the end.
>
> Signed-off-by: Sven Strickroth <sven@cs-ware.de>
> ---

Thanks.

I am not qualified to judge the correctness of the assertion that
MSVC at or more recent than version 1900 does not need the
correction and will wait for Windows folks to Ack.

Thanks.

>  compat/snprintf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/compat/snprintf.c b/compat/snprintf.c
> index 42ea1ac..0b11688 100644
> --- a/compat/snprintf.c
> +++ b/compat/snprintf.c
> @@ -9,7 +9,7 @@
>   * always have room for a trailing NUL byte.
>   */
>  #ifndef SNPRINTF_SIZE_CORR
> -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)
> +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)
>  #define SNPRINTF_SIZE_CORR 1
>  #else
>  #define SNPRINTF_SIZE_CORR 0

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more
  2016-03-29 16:25 [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more Sven Strickroth
  2016-03-29 16:43 ` Junio C Hamano
@ 2016-03-29 19:09 ` Sebastian Schuberth
  2016-03-29 19:13   ` Sven Strickroth
  1 sibling, 1 reply; 7+ messages in thread
From: Sebastian Schuberth @ 2016-03-29 19:09 UTC (permalink / raw)
  To: Sven Strickroth; +Cc: Git List, Junio C Hamano, blees

On Tue, Mar 29, 2016 at 6:25 PM, Sven Strickroth <sven@cs-ware.de> wrote:

> In MSVC2015 the behavior of vsnprintf was changed.
> W/o this fix there is one character missing at the end.

How about adding a link to [1] in the commit message and quoting the
central "Beginning with the UCRT in Visual Studio 2015 and Windows 10,
vsnprintf is no longer identical to _vsnprintf. The vsnprintf function
complies with the C99 standard; _vnsprintf is retained for backward
compatibility" statement?

[1] https://msdn.microsoft.com/en-us/library/1kt27hek.aspx

-- 
Sebastian Schuberth

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more
  2016-03-29 19:09 ` Sebastian Schuberth
@ 2016-03-29 19:13   ` Sven Strickroth
  2016-03-29 19:20     ` Sebastian Schuberth
  0 siblings, 1 reply; 7+ messages in thread
From: Sven Strickroth @ 2016-03-29 19:13 UTC (permalink / raw)
  To: Sebastian Schuberth; +Cc: Git List, Junio C Hamano, blees

"Beginning with the UCRT in Visual Studio 2015 and Windows 10,
vsnprintf is no longer identical to _vsnprintf. The vsnprintf function
complies with the C99 standard; _vnsprintf is retained for backward
compatibility" [1]

W/o this fix there is one character missing at the end.

[1] https://msdn.microsoft.com/en-us/library/1kt27hek.aspx

Signed-off-by: Sven Strickroth <sven@cs-ware.de>
---
 compat/snprintf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/snprintf.c b/compat/snprintf.c
index 42ea1ac..0b11688 100644
--- a/compat/snprintf.c
+++ b/compat/snprintf.c
@@ -9,7 +9,7 @@
  * always have room for a trailing NUL byte.
  */
 #ifndef SNPRINTF_SIZE_CORR
-#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)
+#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)
 #define SNPRINTF_SIZE_CORR 1
 #else
 #define SNPRINTF_SIZE_CORR 0
-- 
2.7.4.windows.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more
  2016-03-29 19:13   ` Sven Strickroth
@ 2016-03-29 19:20     ` Sebastian Schuberth
  2016-03-30  7:49       ` Johannes Schindelin
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastian Schuberth @ 2016-03-29 19:20 UTC (permalink / raw)
  To: Sven Strickroth; +Cc: Git List, Junio C Hamano, blees

On Tue, Mar 29, 2016 at 9:13 PM, Sven Strickroth <sven@cs-ware.de> wrote:

> diff --git a/compat/snprintf.c b/compat/snprintf.c
> index 42ea1ac..0b11688 100644
> --- a/compat/snprintf.c
> +++ b/compat/snprintf.c
> @@ -9,7 +9,7 @@
>   * always have room for a trailing NUL byte.
>   */
>  #ifndef SNPRINTF_SIZE_CORR
> -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)
> +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)
>  #define SNPRINTF_SIZE_CORR 1
>  #else
>  #define SNPRINTF_SIZE_CORR 0

I wonder if the logic is (and was) sensible here. We assume that every
non-__GNUC__ and non-_MSC_VER compiler on Windows requires the
correction. Wouldn't it make sense to not assume requiring the
correction unless we know the compiler has this bug? That is,
shouldn't this better say

#if defined(WIN32) && (defined(__GNUC__) && __GNUC__ < 4) ||
(defined(_MSC_VER) && _MSC_VER < 1900))
#define SNPRINTF_SIZE_CORR 1
#else
#define SNPRINTF_SIZE_CORR 0

-- 
Sebastian Schuberth

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more
  2016-03-29 19:20     ` Sebastian Schuberth
@ 2016-03-30  7:49       ` Johannes Schindelin
  2016-03-30  7:57         ` Sebastian Schuberth
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2016-03-30  7:49 UTC (permalink / raw)
  To: Sebastian Schuberth; +Cc: Sven Strickroth, Git List, Junio C Hamano, blees

Hi Sven & Sebastian,

On Tue, 29 Mar 2016, Sebastian Schuberth wrote:

> On Tue, Mar 29, 2016 at 9:13 PM, Sven Strickroth <sven@cs-ware.de> wrote:

ACK on the patch.

> > diff --git a/compat/snprintf.c b/compat/snprintf.c
> > index 42ea1ac..0b11688 100644
> > --- a/compat/snprintf.c
> > +++ b/compat/snprintf.c
> > @@ -9,7 +9,7 @@
> >   * always have room for a trailing NUL byte.
> >   */
> >  #ifndef SNPRINTF_SIZE_CORR
> > -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)
> > +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)
> >  #define SNPRINTF_SIZE_CORR 1
> >  #else
> >  #define SNPRINTF_SIZE_CORR 0
> 
> I wonder if the logic is (and was) sensible here. We assume that every
> non-__GNUC__ and non-_MSC_VER compiler on Windows requires the
> correction. Wouldn't it make sense to not assume requiring the
> correction unless we know the compiler has this bug? That is,
> shouldn't this better say
> 
> #if defined(WIN32) && (defined(__GNUC__) && __GNUC__ < 4) ||
> (defined(_MSC_VER) && _MSC_VER < 1900))
> #define SNPRINTF_SIZE_CORR 1
> #else
> #define SNPRINTF_SIZE_CORR 0

Since the standard on Windows always was MS Visual C, it should be assumed
that compilers *other* than GCC followed Visual C's lead.

Of course, evidence speaks louder than assumptions.

Therefore I would prefer to keep the current version, at least until we
encounter a case where it is incorrect.

Thanks,
Johannes

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more
  2016-03-30  7:49       ` Johannes Schindelin
@ 2016-03-30  7:57         ` Sebastian Schuberth
  0 siblings, 0 replies; 7+ messages in thread
From: Sebastian Schuberth @ 2016-03-30  7:57 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Sven Strickroth, Git List, Junio C Hamano, blees

On Wed, Mar 30, 2016 at 9:49 AM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:

>> >  #ifndef SNPRINTF_SIZE_CORR
>> > -#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4)
>> > +#if defined(WIN32) && (!defined(__GNUC__) || __GNUC__ < 4) && (!defined(_MSC_VER) || _MSC_VER < 1900)
>> >  #define SNPRINTF_SIZE_CORR 1
>> >  #else
>> >  #define SNPRINTF_SIZE_CORR 0
>>
>> I wonder if the logic is (and was) sensible here. We assume that every
>> non-__GNUC__ and non-_MSC_VER compiler on Windows requires the
>> correction. Wouldn't it make sense to not assume requiring the
>> correction unless we know the compiler has this bug? That is,
>> shouldn't this better say
>>
>> #if defined(WIN32) && (defined(__GNUC__) && __GNUC__ < 4) ||
>> (defined(_MSC_VER) && _MSC_VER < 1900))
>> #define SNPRINTF_SIZE_CORR 1
>> #else
>> #define SNPRINTF_SIZE_CORR 0
>
> Since the standard on Windows always was MS Visual C, it should be assumed
> that compilers *other* than GCC followed Visual C's lead.
>
> Of course, evidence speaks louder than assumptions.
>
> Therefore I would prefer to keep the current version, at least until we
> encounter a case where it is incorrect.

Fine with me. It's probably better not to change the logic as we
wouldn't know whether this would break things for some exotic compiler
currently in use to compile Git.

Also ACK from my side on the path then.

-- 
Sebastian Schuberth

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-03-30  7:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-29 16:25 [PATCH 1/2] MSVC: vsnprintf in Visual Studio 2015 doesn't need SNPRINTF_SIZE_CORR any more Sven Strickroth
2016-03-29 16:43 ` Junio C Hamano
2016-03-29 19:09 ` Sebastian Schuberth
2016-03-29 19:13   ` Sven Strickroth
2016-03-29 19:20     ` Sebastian Schuberth
2016-03-30  7:49       ` Johannes Schindelin
2016-03-30  7:57         ` Sebastian Schuberth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.