On 11/25/17, Ozkan Sezer <[email protected]> wrote:
> See the attached three patches:
>
>
> #1: fix mixed declarations and code in win32_ioctl.c:
>
> lib/driver/MSWindows/win32_ioctl.c: In function
> 'audio_play_msf_win32ioctl':
> lib/driver/MSWindows/win32_ioctl.c:193:3: warning: ISO C90 forbids
> mixed declarations and code
>
>
> #2: fix 'strndup shadows a built-in function' warnings:
>
> if strndup() is not available, the build log is plagued with the
> following warnings:
> lib/driver/cdio_private.h:46:21: warning: declaration of 'strndup'
> shadows a built-in function
>
> So, rename the replacement inline strndup to libcdio_strdup, and
> define strndup as libcdio_strndup.
>
>
> #3: do not use sleep() for windows.
>
> _sleep() has long been deprecated and no longer prototyped in stdlib.h,
> despite the fact that msvcrt.dll still exports it. therefore, undefine
> HAVE_SLEEP when targeting windows, use Sleep win32 api function instead.

The list archive doesn't contain the attached patches. Some ridiculous
filter ate them??  Re-attaching them after renaming *.patch to *.txt,
maybe they arrive this time..

--
O.S.
From a10ff8743636277ceb2b3b7d58e0a594aa45aa76 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[email protected]>
Date: Sat, 25 Nov 2017 14:15:56 +0300
Subject: [PATCH 1/3] fix mixed declarations and code in win32_ioctl.c:

lib/driver/MSWindows/win32_ioctl.c: In function 'audio_play_msf_win32ioctl':
lib/driver/MSWindows/win32_ioctl.c:193:3: warning: ISO C90 forbids mixed 
declarations and code
---
 lib/driver/MSWindows/win32_ioctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/driver/MSWindows/win32_ioctl.c 
b/lib/driver/MSWindows/win32_ioctl.c
index 29de8e1..ea65bae 100644
--- a/lib/driver/MSWindows/win32_ioctl.c
+++ b/lib/driver/MSWindows/win32_ioctl.c
@@ -181,6 +181,7 @@ audio_play_msf_win32ioctl (void *p_user_data, msf_t 
*p_start_msf,
   const _img_private_t *p_env = p_user_data;
   CDROM_PLAY_AUDIO_MSF play;
   DWORD dw_bytes_returned;
+  bool b_success;
 
   play.StartingM = cdio_from_bcd8(p_start_msf->m);
   play.StartingS = cdio_from_bcd8(p_start_msf->s);
@@ -190,7 +191,7 @@ audio_play_msf_win32ioctl (void *p_user_data, msf_t 
*p_start_msf,
   play.EndingS   = cdio_from_bcd8(p_end_msf->s);
   play.EndingF   = cdio_from_bcd8(p_end_msf->f);
 
-  bool b_success =
+  b_success =
     DeviceIoControl(p_env->h_device_handle, IOCTL_CDROM_PLAY_AUDIO_MSF,
                     &play, sizeof(play), NULL, 0, &dw_bytes_returned, NULL);
 
-- 
1.8.5.5

From 8144dedfef55db5d7f756e8e8c17a00f4e43b56f Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[email protected]>
Date: Sat, 25 Nov 2017 14:21:02 +0300
Subject: [PATCH 2/3] fix 'strndup shadows a built-in function' warnings:

if strndup() is not available, the build log is plagued with the
following warnings:
lib/driver/cdio_private.h:46:21: warning: declaration of 'strndup' shadows a 
built-in function

So, rename the replacement inline strndup to libcdio_strdup, and
define strndup as libcdio_strndup.
---
 lib/driver/cdio_private.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/driver/cdio_private.h b/lib/driver/cdio_private.h
index 717c188..0480c31 100644
--- a/lib/driver/cdio_private.h
+++ b/lib/driver/cdio_private.h
@@ -43,7 +43,9 @@ extern "C" {
 #endif /* __cplusplus */
 
 #ifndef HAVE_STRNDUP
-static inline char *strndup(const char *s, size_t n)
+#undef  strndup
+#define strndup libcdio_strndup
+static inline char *libcdio_strndup(const char *s, size_t n)
 {
     char *result;
     size_t len = strlen (s);
-- 
1.8.5.5

From 810c22c97100e13bfe73f84dc4a00ae0f9a03931 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[email protected]>
Date: Sat, 25 Nov 2017 14:32:28 +0300
Subject: [PATCH 3/3] do not use sleep() for windows.

_sleep() has long been deprecated and no longer prototyped in stdlib.h,
despite the fact that msvcrt.dll still exports it. therefore, undefine
HAVE_SLEEP when targeting windows, use Sleep win32 api function instead.
---
 example/cdchange.c      | 3 ++-
 test/driver/mmc_read.c  | 9 ++++++---
 test/driver/mmc_write.c | 9 ++++++---
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/example/cdchange.c b/example/cdchange.c
index 2c43b6c..37b1b1f 100644
--- a/example/cdchange.c
+++ b/example/cdchange.c
@@ -43,8 +43,9 @@
 #ifdef HAVE_WINDOWS_H
 #include <windows.h>
 #endif
-#if !defined(HAVE_SLEEP) && defined(_WIN32)
+#ifdef _WIN32
 #include <windows.h>
+#undef sleep
 #define sleep(s) Sleep(1000*s)
 #endif
 
diff --git a/test/driver/mmc_read.c b/test/driver/mmc_read.c
index 3455585..199b2e2 100644
--- a/test/driver/mmc_read.c
+++ b/test/driver/mmc_read.c
@@ -39,12 +39,15 @@
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
+#ifdef _WIN32
+#  undef HAVE_SLEEP
+#endif
 #if !defined(HAVE_SLEEP)
-#  if defined(HAVE_USLEEP)
-#     define sleep(s) usleep(1000000*s)
-#  elif defined(_WIN32)
+#  if defined(_WIN32)
 #     include <windows.h>
 #     define sleep(s) Sleep(1000*s)
+#  elif defined(HAVE_USLEEP)
+#     define sleep(s) usleep(1000000*s)
 #  else
 #     define sleep(s) { int i; for(i=0; i<=1000*s; i++); }
 #  endif
diff --git a/test/driver/mmc_write.c b/test/driver/mmc_write.c
index 45884cc..82d55a4 100644
--- a/test/driver/mmc_write.c
+++ b/test/driver/mmc_write.c
@@ -39,12 +39,15 @@
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+#ifdef _WIN32
+#  undef HAVE_SLEEP
+#endif
 #if !defined(HAVE_SLEEP)
-#  if defined(HAVE_USLEEP)
-#     define sleep(s) usleep(1000000*s)
-#  elif defined(_WIN32)
+#  if defined(_WIN32)
 #     include <windows.h>
 #     define sleep(s) Sleep(1000*s)
+#  elif defined(HAVE_USLEEP)
+#     define sleep(s) usleep(1000000*s)
 #  else
 #     define sleep(s) { int i; for(i=0; i<=1000*s; i++); }
 #  endif
-- 
1.8.5.5

Reply via email to