Skip to content

Commit

Permalink
libmctp-intel: fix tests
Browse files Browse the repository at this point in the history
Summary:
The current revision of code upstream in this repository
appears to fail to compile with later versions of GCC.  Fix them.

```
| build-halfdome/tmp/work/armv7at2hf-vfp-fb-linux-gnueabi/libmctp-intel/1.0+gitAUTOINC+d530c2271e-r1/git/tests/test_astlpc.c:98:26: error: array subscript 2 is above array bounds of 'uint8_t[2]' {aka 'unsigned char[2]'} [-Werror=array-bounds]
|    98 |                 mmio->kcs[reg] = val;
|       |                 ~~~~~~~~~^~~~~
| build-halfdome/tmp/work/armv7at2hf-vfp-fb-linux-gnueabi/libmctp-intel/1.0+gitAUTOINC+d530c2271e-r1/git/tests/test_astlpc.c:63:17: note: while referencing 'kcs'
|    63 |         uint8_t kcs[2];
```

Submitted upstream at Intel-BMC/libmctp#1

Test Plan: Build passes.

Reviewed By: GoldenBug

fbshipit-source-id: d48d3c787bccea767d29de8879c72ac93e20961f
  • Loading branch information
williamspatrick authored and facebook-github-bot committed Jun 14, 2022
1 parent 5562336 commit 3b2f6bb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
From 197fb58e40863ad07cc571c7a38e6581f74ee09f Mon Sep 17 00:00:00 2001
From: Patrick Williams <[email protected]>
Date: Mon, 13 Jun 2022 17:12:03 -0500
Subject: [PATCH] test: astlpc: fix compile warning

With the GCC found in openbmc/openbmc master, we are observing the
following:

```
| build-halfdome/tmp/work/armv7at2hf-vfp-fb-linux-gnueabi/libmctp-intel/1.0+gitAUTOINC+d530c2271e-r1/git/tests/test_astlpc.c:98:26: error: array subscript 2 is above array bounds of 'uint8_t[2]' {aka 'unsigned char[2]'} [-Werror=array-bounds]
| 98 | mmio->kcs[reg] = val;
| | ~~~~~~~~~^~~~~
| build-halfdome/tmp/work/armv7at2hf-vfp-fb-linux-gnueabi/libmctp-intel/1.0+gitAUTOINC+d530c2271e-r1/git/tests/test_astlpc.c:63:17: note: while referencing 'kcs'
| 63 | uint8_t kcs[2];
```

Fix this by being explicit about the register access (enum to int map).
---
tests/test_astlpc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/test_astlpc.c b/tests/test_astlpc.c
index 0e0dcca..9ecd787 100644
--- a/tests/test_astlpc.c
+++ b/tests/test_astlpc.c
@@ -94,7 +94,7 @@ int mctp_astlpc_mmio_kcs_write(void *data, enum mctp_binding_astlpc_kcs_reg reg,

if (reg == MCTP_ASTLPC_KCS_REG_STATUS)
mmio->kcs[reg] = val & ~0xaU;
- else
+ else if (reg == MCTP_ASTLPC_KCS_REG_DATA)
mmio->kcs[reg] = val;

mctp_prdebug("%s: 0x%hhx to %s", __func__, val,
--
2.31.1

1 change: 1 addition & 0 deletions common/recipes-lib/mctp/libmctp-intel_git.bb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SRC_URI = "git://github.com/Intel-BMC/libmctp.git;protocol=https;branch=master \
file://0001-Remove-unknown-i2c-smbus.h.patch \
file://0002-Build-as-shared-library.patch \
file://0003-Customize-buffer-size.patch \
file://0004-test-astlpc-fix-compile-warning.patch \
"
SRCREV = "d530c2271e1f9ff5d76a170c0abd64bd03ef40fd"
SRC_URI[md5sum] = "1c7db87fb8fa946b03d91fff08b0825a"
Expand Down

0 comments on commit 3b2f6bb

Please sign in to comment.