Files
OpenBMC/meta-luxshare/meta-common/recipes-utilities/i3c-tools/files/0001-Output-error-message-for-invalid-device.patch
T

52 lines
1.4 KiB
Diff
Raw Normal View History

2026-04-23 17:07:55 +08:00
From 195d528024bda107f9b7ab883883db9d0a917f3d Mon Sep 17 00:00:00 2001
From: Jonathan Doman <jonathan.doman@intel.com>
Date: Fri, 11 Mar 2022 11:58:55 -0800
Subject: [PATCH] Output error message for invalid device
Lack of error message when user provided invalid device results in
confusion. Make it clear what is wrong.
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Upstream-Status: Pending
---
i3ctransfer.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/i3ctransfer.c b/i3ctransfer.c
index 816b9ad..413f547 100644
--- a/i3ctransfer.c
+++ b/i3ctransfer.c
@@ -103,9 +103,9 @@ static void print_rx_data(struct i3c_ioc_priv_xfer *xfer)
int main(int argc, char *argv[])
{
struct i3c_ioc_priv_xfer *xfers;
- int file, ret, opt, i;
+ int file = -1, ret, opt, i;
int nxfers = 0;
- char *device;
+ char *device = NULL;
while ((opt = getopt_long(argc, argv, sopts, lopts, NULL)) != EOF) {
switch (opt) {
@@ -130,12 +130,13 @@ int main(int argc, char *argv[])
}
}
- if (!device)
- exit(EXIT_FAILURE);
+ if (device)
+ file = open(device, O_RDWR);
- file = open(device, O_RDWR);
- if (file < 0)
+ if (file < 0) {
+ fprintf(stderr, "Error: %s\n", device ? strerror(errno) : "No device provided");
exit(EXIT_FAILURE);
+ }
xfers = (struct i3c_ioc_priv_xfer *)calloc(nxfers, sizeof(*xfers));
if (!xfers)
--
2.35.1