Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Mucse] [Deepin Kernel SIG] Fix compile errors with clang-19 #495

Merged

Conversation

Avenger-285714
Copy link
Collaborator

No description provided.

Follow error with clang-19:

drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.c:517:18: error: array index 0 is past the end of the array (that has type 'char[0]', cast to 'int *') [-Werror,-Warray-bounds]
  517 |                 ret = ((int *)(cookie->priv))[0];
      |                                ^              ~
drivers/net/ethernet/mucse/rnpgbe/rnpgbe_mbx_fw.h:29:2: note: array 'priv' declared here
   29 |         char priv[0];
      |         ^
1 error generated.

To fix this, define a MAX_PRIV_LEN just like what
'struct mbx_req_cookie' at 'rnp_type.h' does.

Signed-off-by: WangYuli <wangyuli@uniontech.com>
Fix follow compile errors with clang-19:

drivers/net/ethernet/mucse/rnpgbe/rnpgbe_chip.c:3394:10: error: explicitly assigning value of variable of type 'int' to itself [-Werror,-Wself-assign]
 3394 |         voltage = voltage;
      |         ~~~~~~~ ^ ~~~~~~~
1 error generated.

drivers/net/ethernet/mucse/rnp/rnp_n10.c:4208:10: error: explicitly assigning value of variable of type 'int' to itself [-Werror,-Wself-assign]
 4208 |         voltage = voltage;
      |         ~~~~~~~ ^ ~~~~~~~
1 error generated.

Signed-off-by: WangYuli <wangyuli@uniontech.com>
Fix follow errors with clang-19:

drivers/net/ethernet/mucse/rnp/rnp_main.c:6165:24: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
 6165 |                 } else if ((protocol == htons(ETH_P_8021Q))) {
      |                             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mucse/rnp/rnp_main.c:6165:24: note: remove extraneous parentheses around the comparison to silence this warning
 6165 |                 } else if ((protocol == htons(ETH_P_8021Q))) {
      |                            ~         ^                    ~
drivers/net/ethernet/mucse/rnp/rnp_main.c:6165:24: note: use '=' to turn this equality comparison into an assignment
 6165 |                 } else if ((protocol == htons(ETH_P_8021Q))) {
      |                                      ^~
      |                                      =
1 error generated.

drivers/net/ethernet/mucse/rnp/rnp_n10.c:3329:30: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
 3329 |                         if ((hw->force_speed_stat ==
      |                              ~~~~~~~~~~~~~~~~~~~~~^~
 3330 |                              FORCE_SPEED_STAT_DISABLED)) {
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/mucse/rnp/rnp_n10.c:3329:30: note: remove extraneous parentheses around the comparison to silence this warning
 3329 |                         if ((hw->force_speed_stat ==
      |                             ~                     ^
 3330 |                              FORCE_SPEED_STAT_DISABLED)) {
      |                                                       ~
drivers/net/ethernet/mucse/rnp/rnp_n10.c:3329:30: note: use '=' to turn this equality comparison into an assignment
 3329 |                         if ((hw->force_speed_stat ==
      |                                                   ^~
      |                                                   =
1 error generated.

Signed-off-by: WangYuli <wangyuli@uniontech.com>
Fix follow error with clang-19:

drivers/net/ethernet/mucse/rnpgbevf/rnpgbevf_ethtool.c:143:3: error: variable 'advertising' is uninitialized when used here [-Werror,-Wuninitialized]
  143 |                 advertising |= ADVERTISED_FIBRE | ADVERTISED_1000baseKX_Full;
      |                 ^~~~~~~~~~~
drivers/net/ethernet/mucse/rnpgbevf/rnpgbevf_ethtool.c:131:28: note: initialize the variable 'advertising' to silence this warning
  131 |         u32 supported, advertising;
      |                                   ^
      |                                    = 0
1 error generated.

Signed-off-by: WangYuli <wangyuli@uniontech.com>
@Avenger-285714 Avenger-285714 merged commit bab2ac7 into deepin-community:linux-6.6.y Nov 25, 2024
3 of 5 checks passed
@deepin-ci-robot
Copy link

deepin pr auto review

代码审查意见:

  1. rnp_xmit_frame_ring函数中,else if语句的条件判断括号多余,可以删除。
  2. rnp10_set_link_ksettings函数中,advertising_link_speed为0时打印信息,但未处理错误返回值,应添加错误处理逻辑。
  3. rnp_get_thermal_sensor_data_hw_ops_n10rnpgbe_get_thermal_sensor_data_hw_ops_n500函数中,voltage = voltage;这行代码是多余的,可以删除。
  4. rnpgbe_mbx_fw.h文件中,struct mbx_req_cookie中的priv数组定义了一个最大长度为64的字符数组,这是一个好的做法,可以避免潜在的缓冲区溢出问题。
  5. rnpgbevf_ethtool.c文件中,rnpgbevf_get_link_ksettings函数中,advertising变量被初始化为0,但在后续代码中未使用,应考虑是否需要初始化或删除该变量。

总体来说,代码的改动是合理的,但需要注意错误处理和潜在的性能优化问题。

@deepin-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from avenger-285714. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Avenger-285714 pushed a commit to KernelSIG-cn/Linux-LTS-CN-6.6-dev that referenced this pull request Dec 29, 2024
These drivers is to support follow ethernet cards:
 *mucse n500/n210 (rnpgbe)
  mucse n500/n210 virtual function (rnpgbevf)
  mucse n10-2ports (rnp)
  mucse n10 virtual function (rnpvf)

Link: deepin-community/kernel#413
Link: deepin-community/kernel#441
Link: deepin-community/kernel#447
Link: deepin-community/kernel#448
Link: deepin-community/kernel#449
Link: deepin-community/kernel#468
Link: deepin-community/kernel#495
Co-developed-by: WangYuli <wangyuli@uniontech.com>
Signed-off-by: WangYuli <wangyuli@uniontech.com>
Signed-off-by: Dong Yibo <dong100@mucse.com>
Signed-off-by: WangYuli <wangyuli@uniontech.com>
Avenger-285714 pushed a commit to KernelSIG-cn/Linux-LTS-CN-6.6-dev that referenced this pull request Jan 4, 2025
These drivers is to support follow ethernet cards:
 *mucse n500/n210 (rnpgbe)
  mucse n500/n210 virtual function (rnpgbevf)
  mucse n10-2ports (rnp)
  mucse n10 virtual function (rnpvf)

Link: deepin-community/kernel#413
Link: deepin-community/kernel#441
Link: deepin-community/kernel#447
Link: deepin-community/kernel#448
Link: deepin-community/kernel#449
Link: deepin-community/kernel#468
Link: deepin-community/kernel#495
Co-developed-by: WangYuli <wangyuli@uniontech.com>
Signed-off-by: WangYuli <wangyuli@uniontech.com>
Signed-off-by: Dong Yibo <dong100@mucse.com>
Signed-off-by: WangYuli <wangyuli@uniontech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants