diff mbox series

[FFmpeg-devel] lavu: use address-of operator checking clock_gettime

Message ID 20201208221825.62957-1-epirat07@gmail.com
State Accepted
Commit d67c6c7f6f57f0ccdc26fcf1f046ca3fa2e93e59
Headers show
Series [FFmpeg-devel] lavu: use address-of operator checking clock_gettime | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Marvin Scholz Dec. 8, 2020, 10:18 p.m. UTC
When targeting a recent enough macOS/iOS version that has clock_gettime
it won't be a weak symbol, in which case clang warns for this check
as it's always true:

  warning: address of function 'clock_gettime' will always
  evaluate to 'true'

This warning is silenced by using the address-of operator to make
the intent explicit.
---
 libavutil/time.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Marvin Scholz Dec. 17, 2020, 8:28 p.m. UTC | #1
Ping

On 8 Dec 2020, at 23:18, Marvin Scholz wrote:

> When targeting a recent enough macOS/iOS version that has clock_gettime
> it won't be a weak symbol, in which case clang warns for this check
> as it's always true:
>
>   warning: address of function 'clock_gettime' will always
>   evaluate to 'true'
>
> This warning is silenced by using the address-of operator to make
> the intent explicit.
> ---
>  libavutil/time.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/time.c b/libavutil/time.c
> index afa6658aa6..740afc4785 100644
> --- a/libavutil/time.c
> +++ b/libavutil/time.c
> @@ -57,7 +57,7 @@ int64_t av_gettime_relative(void)
>  {
>  #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
>  #ifdef __APPLE__
> -    if (clock_gettime)
> +    if (&clock_gettime)
>  #endif
>      {
>          struct timespec ts;
> @@ -72,7 +72,7 @@ int av_gettime_relative_is_monotonic(void)
>  {
>  #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
>  #ifdef __APPLE__
> -    if (!clock_gettime)
> +    if (!&clock_gettime)
>          return 0;
>  #endif
>      return 1;
> -- 
> 2.24.3 (Apple Git-128)
Marvin Scholz Dec. 23, 2020, 6:20 p.m. UTC | #2
Ping.

On 8 Dec 2020, at 23:18, Marvin Scholz wrote:

> When targeting a recent enough macOS/iOS version that has clock_gettime
> it won't be a weak symbol, in which case clang warns for this check
> as it's always true:
>
>   warning: address of function 'clock_gettime' will always
>   evaluate to 'true'
>
> This warning is silenced by using the address-of operator to make
> the intent explicit.
> ---
>  libavutil/time.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/time.c b/libavutil/time.c
> index afa6658aa6..740afc4785 100644
> --- a/libavutil/time.c
> +++ b/libavutil/time.c
> @@ -57,7 +57,7 @@ int64_t av_gettime_relative(void)
>  {
>  #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
>  #ifdef __APPLE__
> -    if (clock_gettime)
> +    if (&clock_gettime)
>  #endif
>      {
>          struct timespec ts;
> @@ -72,7 +72,7 @@ int av_gettime_relative_is_monotonic(void)
>  {
>  #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
>  #ifdef __APPLE__
> -    if (!clock_gettime)
> +    if (!&clock_gettime)
>          return 0;
>  #endif
>      return 1;
> -- 
> 2.24.3 (Apple Git-128)
diff mbox series

Patch

diff --git a/libavutil/time.c b/libavutil/time.c
index afa6658aa6..740afc4785 100644
--- a/libavutil/time.c
+++ b/libavutil/time.c
@@ -57,7 +57,7 @@  int64_t av_gettime_relative(void)
 {
 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
 #ifdef __APPLE__
-    if (clock_gettime)
+    if (&clock_gettime)
 #endif
     {
         struct timespec ts;
@@ -72,7 +72,7 @@  int av_gettime_relative_is_monotonic(void)
 {
 #if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
 #ifdef __APPLE__
-    if (!clock_gettime)
+    if (!&clock_gettime)
         return 0;
 #endif
     return 1;