diff mbox series

[v8,12/27] gcrypt: test_tls_psk_init should write binary file instead text file.

Message ID 20200912224431.1428-13-luoyonggang@gmail.com (mailing list archive)
State New, archived
Headers show
Series W32, W64 msys2/mingw patches | expand

Commit Message

Yonggang Luo Sept. 12, 2020, 10:44 p.m. UTC
On windows, if open file with "w", it's will automatically convert
"\n" to "\r\n" when writing to file.

Convert unlink to use g_remove.

Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
---
 tests/crypto-tls-psk-helpers.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé Sept. 13, 2020, 3:31 p.m. UTC | #1
On 9/13/20 12:44 AM, Yonggang Luo wrote:
> On windows, if open file with "w", it's will automatically convert
> "\n" to "\r\n" when writing to file.

This is one change.

> 
> Convert unlink to use g_remove.

This is another (unrelated) change.

We expect patches to be atomic (only one change at
a time). Can you split this patch in 2?

> 
> Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
> ---
>  tests/crypto-tls-psk-helpers.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/crypto-tls-psk-helpers.c b/tests/crypto-tls-psk-helpers.c
> index a8395477c3..58888d5537 100644
> --- a/tests/crypto-tls-psk-helpers.c
> +++ b/tests/crypto-tls-psk-helpers.c
> @@ -26,13 +26,15 @@
>  #include "crypto-tls-psk-helpers.h"
>  #include "qemu/sockets.h"
>  
> +#include <glib/gstdio.h>
> +
>  #ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT
>  
>  void test_tls_psk_init(const char *pskfile)
>  {
>      FILE *fp;
>  
> -    fp = fopen(pskfile, "w");
> +    fp = fopen(pskfile, "wb");
>      if (fp == NULL) {
>          g_critical("Failed to create pskfile %s", pskfile);
>          abort();
> @@ -44,7 +46,7 @@ void test_tls_psk_init(const char *pskfile)
>  
>  void test_tls_psk_cleanup(const char *pskfile)
>  {
> -    unlink(pskfile);
> +    g_remove(pskfile);
>  }
>  
>  #endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */
>
diff mbox series

Patch

diff --git a/tests/crypto-tls-psk-helpers.c b/tests/crypto-tls-psk-helpers.c
index a8395477c3..58888d5537 100644
--- a/tests/crypto-tls-psk-helpers.c
+++ b/tests/crypto-tls-psk-helpers.c
@@ -26,13 +26,15 @@ 
 #include "crypto-tls-psk-helpers.h"
 #include "qemu/sockets.h"
 
+#include <glib/gstdio.h>
+
 #ifdef QCRYPTO_HAVE_TLS_TEST_SUPPORT
 
 void test_tls_psk_init(const char *pskfile)
 {
     FILE *fp;
 
-    fp = fopen(pskfile, "w");
+    fp = fopen(pskfile, "wb");
     if (fp == NULL) {
         g_critical("Failed to create pskfile %s", pskfile);
         abort();
@@ -44,7 +46,7 @@  void test_tls_psk_init(const char *pskfile)
 
 void test_tls_psk_cleanup(const char *pskfile)
 {
-    unlink(pskfile);
+    g_remove(pskfile);
 }
 
 #endif /* QCRYPTO_HAVE_TLS_TEST_SUPPORT */