[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dri-devel
Subject:    Re: [PATCH -next] drm/amdgpu: Remove a lot of unnecessary ternary operators
From:       Tom Rix <trix () redhat ! com>
Date:       2023-07-31 16:22:42
Message-ID: a048aa87-5bac-2032-6d5e-929af5cbc8e1 () redhat ! com
[Download RAW message or body]

On 7/31/23 6:26 AM, Ruan Jinjie wrote:
> Ther are many ternary operators, the true or false judgement
> of which is unnecessary in C language semantics.
>
> Signed-off-by: Ruan Jinjie<ruanjinjie@huawei.com>
> ---

snip
>   	data->registry_data.avfs_support =
> -		hwmgr->feature_mask & PP_AVFS_MASK ? true : false;
> +		hwmgr->feature_mask & PP_AVFS_MASK;
>   	data->registry_data.led_dpm_enabled = 1;

These are not equivalent, consider 0xffff & 0x1000 != 1

Tom


[Attachment #3 (text/html)]

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 7/31/23 6:26 AM, Ruan Jinjie wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:20230731132610.2675314-1-ruanjinjie@huawei.com">
      <pre class="moz-quote-pre" wrap="">Ther are many ternary operators, the true or \
false judgement of which is unnecessary in C language semantics.

Signed-off-by: Ruan Jinjie <a class="moz-txt-link-rfc2396E" \
                href="mailto:ruanjinjie@huawei.com">&lt;ruanjinjie@huawei.com&gt;</a>
---
</pre>
    </blockquote>
    <span style="white-space: pre-wrap">
</span><br>
    snip<br>
    <blockquote type="cite"
      cite="mid:20230731132610.2675314-1-ruanjinjie@huawei.com">
      <pre class="moz-quote-pre" wrap="">
 	data-&gt;registry_data.avfs_support =
-		hwmgr-&gt;feature_mask &amp; PP_AVFS_MASK ? true : false;
+		hwmgr-&gt;feature_mask &amp; PP_AVFS_MASK;
 	data-&gt;registry_data.led_dpm_enabled = 1;</pre>
    </blockquote>
    <p>These are not equivalent, consider 0xffff &amp; 0x1000 != 1<br>
    </p>
    <p>Tom</p>
    <br>
  </body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic