git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] win32: check for NULL when creating thread
@ 2023-01-31 14:49 Rose via GitGitGadget
  2023-01-31 14:53 ` [PATCH v2] win32: check for NULL after " Rose via GitGitGadget
  0 siblings, 1 reply; 7+ messages in thread
From: Rose via GitGitGadget @ 2023-01-31 14:49 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

Check for NULL handles, not "INVALID_HANDLE,"
as CreateThread guarantees a valid handle in most cases.

The return value for failed thread creation is NULL,
not INVALID_HANDLE_VALUE, unlike other Windows
API functions.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    win32: check for NULL when creating thread
    
    Check for NULL handles, not "INVALID_HANDLE," as CreateThread guarantees
    a valid handle in most cases.
    
    The return value for failed thread creation is NULL, not
    INVALID_HANDLE_VALUE, unlike other Windows API functions.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1445%2FAtariDreams%2FhThread-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1445/AtariDreams/hThread-v1
Pull-Request: https://github.com/git/git/pull/1445

 compat/winansi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/winansi.c b/compat/winansi.c
index 3abe8dd5a27..f83610f684d 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -644,7 +644,7 @@ void winansi_init(void)
 
 	/* start console spool thread on the pipe's read end */
 	hthread = CreateThread(NULL, 0, console_thread, NULL, 0, NULL);
-	if (hthread == INVALID_HANDLE_VALUE)
+	if (!hthread)
 		die_lasterr("CreateThread(console_thread) failed");
 
 	/* schedule cleanup routine */

base-commit: 2fc9e9ca3c7505bc60069f11e7ef09b1aeeee473
-- 
gitgitgadget

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

* [PATCH v2] win32: check for NULL after creating thread
  2023-01-31 14:49 [PATCH] win32: check for NULL when creating thread Rose via GitGitGadget
@ 2023-01-31 14:53 ` Rose via GitGitGadget
  2023-02-01 14:40   ` [PATCH v3] " Rose via GitGitGadget
  0 siblings, 1 reply; 7+ messages in thread
From: Rose via GitGitGadget @ 2023-01-31 14:53 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

Check for NULL handles, not "INVALID_HANDLE,"
as CreateThread guarantees a valid handle in most cases.

The return value for failed thread creation is NULL,
not INVALID_HANDLE_VALUE, unlike other Windows
API functions.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    win32: check for NULL after creating thread
    
    Check for NULL handles, not "INVALID_HANDLE," as CreateThread guarantees
    a valid handle in most cases.
    
    The return value for failed thread creation is NULL, not
    INVALID_HANDLE_VALUE, unlike other Windows API functions.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1445%2FAtariDreams%2FhThread-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1445/AtariDreams/hThread-v2
Pull-Request: https://github.com/git/git/pull/1445

Range-diff vs v1:

 1:  e75d15e42f4 ! 1:  c956cafdec9 win32: check for NULL when creating thread
     @@ Metadata
      Author: Seija Kijin <doremylover123@gmail.com>
      
       ## Commit message ##
     -    win32: check for NULL when creating thread
     +    win32: check for NULL after creating thread
      
          Check for NULL handles, not "INVALID_HANDLE,"
          as CreateThread guarantees a valid handle in most cases.


 compat/winansi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/winansi.c b/compat/winansi.c
index 3abe8dd5a27..f83610f684d 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -644,7 +644,7 @@ void winansi_init(void)
 
 	/* start console spool thread on the pipe's read end */
 	hthread = CreateThread(NULL, 0, console_thread, NULL, 0, NULL);
-	if (hthread == INVALID_HANDLE_VALUE)
+	if (!hthread)
 		die_lasterr("CreateThread(console_thread) failed");
 
 	/* schedule cleanup routine */

base-commit: 2fc9e9ca3c7505bc60069f11e7ef09b1aeeee473
-- 
gitgitgadget

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

* [PATCH v3] win32: check for NULL after creating thread
  2023-01-31 14:53 ` [PATCH v2] win32: check for NULL after " Rose via GitGitGadget
@ 2023-02-01 14:40   ` Rose via GitGitGadget
  2023-02-01 21:51     ` Johannes Sixt
  2023-02-01 22:20     ` [PATCH v4] compat/winansi: check for errors of CreateThread() correctly Rose via GitGitGadget
  0 siblings, 2 replies; 7+ messages in thread
From: Rose via GitGitGadget @ 2023-02-01 14:40 UTC (permalink / raw)
  To: git; +Cc: Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

Check for NULL handles, not "INVALID_HANDLE,"
as CreateThread guarantees a valid handle in most cases.

The return value for failed thread creation is NULL,
not INVALID_HANDLE_VALUE, unlike other Windows API functions.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    win32: check for NULL after creating thread
    
    Check for NULL handles, not "INVALID_HANDLE," as CreateThread guarantees
    a valid handle in most cases.
    
    The return value for failed thread creation is NULL, not
    INVALID_HANDLE_VALUE, unlike other Windows API functions.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1445%2FAtariDreams%2FhThread-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1445/AtariDreams/hThread-v3
Pull-Request: https://github.com/git/git/pull/1445

Range-diff vs v2:

 1:  c956cafdec9 ! 1:  1cbc43e0d82 win32: check for NULL after creating thread
     @@ Commit message
          as CreateThread guarantees a valid handle in most cases.
      
          The return value for failed thread creation is NULL,
     -    not INVALID_HANDLE_VALUE, unlike other Windows
     -    API functions.
     +    not INVALID_HANDLE_VALUE, unlike other Windows API functions.
      
          Signed-off-by: Seija Kijin <doremylover123@gmail.com>
      


 compat/winansi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/winansi.c b/compat/winansi.c
index 3abe8dd5a27..f83610f684d 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -644,7 +644,7 @@ void winansi_init(void)
 
 	/* start console spool thread on the pipe's read end */
 	hthread = CreateThread(NULL, 0, console_thread, NULL, 0, NULL);
-	if (hthread == INVALID_HANDLE_VALUE)
+	if (!hthread)
 		die_lasterr("CreateThread(console_thread) failed");
 
 	/* schedule cleanup routine */

base-commit: 2fc9e9ca3c7505bc60069f11e7ef09b1aeeee473
-- 
gitgitgadget

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

* Re: [PATCH v3] win32: check for NULL after creating thread
  2023-02-01 14:40   ` [PATCH v3] " Rose via GitGitGadget
@ 2023-02-01 21:51     ` Johannes Sixt
  2023-02-01 22:20     ` [PATCH v4] compat/winansi: check for errors of CreateThread() correctly Rose via GitGitGadget
  1 sibling, 0 replies; 7+ messages in thread
From: Johannes Sixt @ 2023-02-01 21:51 UTC (permalink / raw)
  To: Rose via GitGitGadget; +Cc: Seija Kijin, git

Am 01.02.23 um 15:40 schrieb Rose via GitGitGadget:
> From: Seija Kijin <doremylover123@gmail.com>
> 
> Check for NULL handles, not "INVALID_HANDLE,"
> as CreateThread guarantees a valid handle in most cases.
> 
> The return value for failed thread creation is NULL,
> not INVALID_HANDLE_VALUE, unlike other Windows API functions.

Nice catch!

The subject line sounds as if an error check was missing, but that is
not true. I'd phrase it

	compat/winansi: check for errors of CreateThread() correctly

Then drop the first sentence of the message body as it is very handwavy:
talking about "most cases" is not helpful if the few other cases are not
enumerated. And the subsequent sentence is to the point and very helpful
(substitute "CreateThread" for "thread creation").

>  compat/winansi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/compat/winansi.c b/compat/winansi.c
> index 3abe8dd5a27..f83610f684d 100644
> --- a/compat/winansi.c
> +++ b/compat/winansi.c
> @@ -644,7 +644,7 @@ void winansi_init(void)
>  
>  	/* start console spool thread on the pipe's read end */
>  	hthread = CreateThread(NULL, 0, console_thread, NULL, 0, NULL);
> -	if (hthread == INVALID_HANDLE_VALUE)
> +	if (!hthread)
>  		die_lasterr("CreateThread(console_thread) failed");
>  
>  	/* schedule cleanup routine */
> 
> base-commit: 2fc9e9ca3c7505bc60069f11e7ef09b1aeeee473

Acked-by: Johannes Sixt <j6t@kdbg.org>

-- Hannes


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

* [PATCH v4] compat/winansi: check for errors of CreateThread() correctly
  2023-02-01 14:40   ` [PATCH v3] " Rose via GitGitGadget
  2023-02-01 21:51     ` Johannes Sixt
@ 2023-02-01 22:20     ` Rose via GitGitGadget
  2023-02-01 22:37       ` Junio C Hamano
  2023-02-01 22:39       ` Johannes Sixt
  1 sibling, 2 replies; 7+ messages in thread
From: Rose via GitGitGadget @ 2023-02-01 22:20 UTC (permalink / raw)
  To: git; +Cc: Johannes Sixt, Rose, Seija Kijin

From: Seija Kijin <doremylover123@gmail.com>

The return value for failed thread creation is NULL,
not INVALID_HANDLE_VALUE, unlike other Windows API functions.

Signed-off-by: Seija Kijin <doremylover123@gmail.com>
---
    win32: check for NULL after creating thread
    
    Check for NULL handles, not "INVALID_HANDLE," as CreateThread guarantees
    a valid handle in most cases.
    
    The return value for failed thread creation is NULL, not
    INVALID_HANDLE_VALUE, unlike other Windows API functions.
    
    Signed-off-by: Seija Kijin doremylover123@gmail.com

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1445%2FAtariDreams%2FhThread-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1445/AtariDreams/hThread-v4
Pull-Request: https://github.com/git/git/pull/1445

Range-diff vs v3:

 1:  1cbc43e0d82 ! 1:  6c4188977e8 win32: check for NULL after creating thread
     @@ Metadata
      Author: Seija Kijin <doremylover123@gmail.com>
      
       ## Commit message ##
     -    win32: check for NULL after creating thread
     -
     -    Check for NULL handles, not "INVALID_HANDLE,"
     -    as CreateThread guarantees a valid handle in most cases.
     +    compat/winansi: check for errors of CreateThread() correctly
      
          The return value for failed thread creation is NULL,
          not INVALID_HANDLE_VALUE, unlike other Windows API functions.


 compat/winansi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/compat/winansi.c b/compat/winansi.c
index 3abe8dd5a27..f83610f684d 100644
--- a/compat/winansi.c
+++ b/compat/winansi.c
@@ -644,7 +644,7 @@ void winansi_init(void)
 
 	/* start console spool thread on the pipe's read end */
 	hthread = CreateThread(NULL, 0, console_thread, NULL, 0, NULL);
-	if (hthread == INVALID_HANDLE_VALUE)
+	if (!hthread)
 		die_lasterr("CreateThread(console_thread) failed");
 
 	/* schedule cleanup routine */

base-commit: 2fc9e9ca3c7505bc60069f11e7ef09b1aeeee473
-- 
gitgitgadget

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

* Re: [PATCH v4] compat/winansi: check for errors of CreateThread() correctly
  2023-02-01 22:20     ` [PATCH v4] compat/winansi: check for errors of CreateThread() correctly Rose via GitGitGadget
@ 2023-02-01 22:37       ` Junio C Hamano
  2023-02-01 22:39       ` Johannes Sixt
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2023-02-01 22:37 UTC (permalink / raw)
  To: Rose via GitGitGadget; +Cc: git, Johannes Sixt, Seija Kijin

"Rose via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Seija Kijin <doremylover123@gmail.com>
>
> The return value for failed thread creation is NULL,
> not INVALID_HANDLE_VALUE, unlike other Windows API functions.
>
> Signed-off-by: Seija Kijin <doremylover123@gmail.com>
> ---

Thanks.  Will queue with the Ack by j6t given earlier.

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

* Re: [PATCH v4] compat/winansi: check for errors of CreateThread() correctly
  2023-02-01 22:20     ` [PATCH v4] compat/winansi: check for errors of CreateThread() correctly Rose via GitGitGadget
  2023-02-01 22:37       ` Junio C Hamano
@ 2023-02-01 22:39       ` Johannes Sixt
  1 sibling, 0 replies; 7+ messages in thread
From: Johannes Sixt @ 2023-02-01 22:39 UTC (permalink / raw)
  To: Rose via GitGitGadget; +Cc: Seija Kijin, git

Am 01.02.23 um 23:20 schrieb Rose via GitGitGadget:
> From: Seija Kijin <doremylover123@gmail.com>
> 
> The return value for failed thread creation is NULL,
> not INVALID_HANDLE_VALUE, unlike other Windows API functions.
> 
> Signed-off-by: Seija Kijin <doremylover123@gmail.com>
> ---
>     win32: check for NULL after creating thread
>     
>     Check for NULL handles, not "INVALID_HANDLE," as CreateThread guarantees
>     a valid handle in most cases.
>     
>     The return value for failed thread creation is NULL, not
>     INVALID_HANDLE_VALUE, unlike other Windows API functions.
>     
>     Signed-off-by: Seija Kijin doremylover123@gmail.com
> 
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1445%2FAtariDreams%2FhThread-v4
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1445/AtariDreams/hThread-v4
> Pull-Request: https://github.com/git/git/pull/1445
> 
> Range-diff vs v3:
> 
>  1:  1cbc43e0d82 ! 1:  6c4188977e8 win32: check for NULL after creating thread
>      @@ Metadata
>       Author: Seija Kijin <doremylover123@gmail.com>
>       
>        ## Commit message ##
>      -    win32: check for NULL after creating thread
>      -
>      -    Check for NULL handles, not "INVALID_HANDLE,"
>      -    as CreateThread guarantees a valid handle in most cases.
>      +    compat/winansi: check for errors of CreateThread() correctly
>       
>           The return value for failed thread creation is NULL,
>           not INVALID_HANDLE_VALUE, unlike other Windows API functions.
> 
> 
>  compat/winansi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/compat/winansi.c b/compat/winansi.c
> index 3abe8dd5a27..f83610f684d 100644
> --- a/compat/winansi.c
> +++ b/compat/winansi.c
> @@ -644,7 +644,7 @@ void winansi_init(void)
>  
>  	/* start console spool thread on the pipe's read end */
>  	hthread = CreateThread(NULL, 0, console_thread, NULL, 0, NULL);
> -	if (hthread == INVALID_HANDLE_VALUE)
> +	if (!hthread)
>  		die_lasterr("CreateThread(console_thread) failed");
>  
>  	/* schedule cleanup routine */
> 
> base-commit: 2fc9e9ca3c7505bc60069f11e7ef09b1aeeee473

This iteration looks good, thank you!

Acked-by: Johannes Sixt <j6t@kdbg.org>

-- Hannes


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

end of thread, other threads:[~2023-02-01 22:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 14:49 [PATCH] win32: check for NULL when creating thread Rose via GitGitGadget
2023-01-31 14:53 ` [PATCH v2] win32: check for NULL after " Rose via GitGitGadget
2023-02-01 14:40   ` [PATCH v3] " Rose via GitGitGadget
2023-02-01 21:51     ` Johannes Sixt
2023-02-01 22:20     ` [PATCH v4] compat/winansi: check for errors of CreateThread() correctly Rose via GitGitGadget
2023-02-01 22:37       ` Junio C Hamano
2023-02-01 22:39       ` Johannes Sixt

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).