Re: [PATCH 2/3] nbd-trdump, nbd-trplay: printf improvements/corrections
Hello Wouter,
Sorry for the slow reply:
I have overlooked your mail, and only today noticed it.
On 3/24/22 18:36, Wouter Verhelst wrote:
On Sat, Mar 19, 2022 at 01:12:26PM +0100, Manfred Spraul wrote:
From: Manfred Spraul <manfred.spraul@de.bosch.com>
Two improvements to the printf output:
- Correct an incorrect printout from nbd-trplay:
When open() on the the log file fails, the tool incorrectly warns
that the disk image is inaccessible.
- Both nbd-trdump and nbd-trplay: Add a warning if unknown options
are encountered.
Signed-off-by: Manfred Spraul <manfred.spraul@de.bosch.com>
---
nbd-trdump.c | 4 ++++
nbd-trplay.c | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/nbd-trdump.c b/nbd-trdump.c
index d914e63..c7c5322 100644
--- a/nbd-trdump.c
+++ b/nbd-trdump.c
@@ -130,14 +130,18 @@ int main(int argc, char**argv) {
break;
default:
printf("TRACE_OPTION ? Unknown type\n");
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trdump.\n");
+
Ups - an unnecessary empty line. I've removed that as well.
}
} else {
printf("TRACE_OPTION ? Unknown FROM_MAGIC\n");
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trdump.\n");
}
break;
default:
printf("? Unknown transaction type %08x\n",magic);
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trdump.\n");
break;
}
diff --git a/nbd-trplay.c b/nbd-trplay.c
index 143d8cb..f98b7df 100644
--- a/nbd-trplay.c
+++ b/nbd-trplay.c
@@ -221,9 +221,11 @@ int main_loop(int logfd, int imagefd) {
break;
default:
printf("TRACE_OPTION ? Unknown type\n");
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trplay.\n");
}
} else {
printf("TRACE_OPTION ? Unknown FROM_MAGIC\n");
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trplay.\n");
}
break;
@@ -301,7 +303,7 @@ int main(int argc, char **argv) {
case 'l':
logfd = open(optarg, O_RDONLY, 0);
if (logfd == -1) {
- printf(" Opening disk image failed, errno %d.", errno);
+ printf(" Opening log file failed, errno %d.", errno);
Please use perror() for these instead.
Updated patch is attached.
Should I resend the whole series?
--
Manfred
From 8af7920b86f7aa4dde18ff46cfad61c5cc3933c5 Mon Sep 17 00:00:00 2001
From: Manfred Spraul <manfred.spraul@de.bosch.com>
Date: Mon, 7 Mar 2022 18:05:45 +0100
Subject: [PATCH 2/3] nbd-trdump, nbd-trplay: printf improvements/corrections
Two improvements to the printf output:
- Correct an incorrect printout from nbd-trplay:
When open() on the the log file fails, the tool incorrectly warns
that the disk image is inaccessible.
- switch for the file open failures in nbd-trplay from printf() to
perror().
- Both nbd-trdump and nbd-trplay: Add a warning if unknown options
are encountered.
Signed-off-by: Manfred Spraul <manfred.spraul@de.bosch.com>
---
V2: switch to perror() added.
---
nbd-trdump.c | 4 ++++
nbd-trplay.c | 6 ++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/nbd-trdump.c b/nbd-trdump.c
index d914e63..c7c5322 100644
--- a/nbd-trdump.c
+++ b/nbd-trdump.c
@@ -130,14 +130,17 @@ int main(int argc, char**argv) {
break;
default:
printf("TRACE_OPTION ? Unknown type\n");
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trdump.\n");
}
} else {
printf("TRACE_OPTION ? Unknown FROM_MAGIC\n");
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trdump.\n");
}
break;
default:
printf("? Unknown transaction type %08x\n",magic);
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trdump.\n");
break;
}
diff --git a/nbd-trplay.c b/nbd-trplay.c
index 143d8cb..7f30cbc 100644
--- a/nbd-trplay.c
+++ b/nbd-trplay.c
@@ -221,9 +221,11 @@ int main_loop(int logfd, int imagefd) {
break;
default:
printf("TRACE_OPTION ? Unknown type\n");
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trplay.\n");
}
} else {
printf("TRACE_OPTION ? Unknown FROM_MAGIC\n");
+ printf(" Further log file evaluation may be incorrect, please upgrade nbd-trplay.\n");
}
break;
@@ -294,14 +296,14 @@ int main(int argc, char **argv) {
case 'i':
imagefd = open(optarg, O_RDWR, 0);
if (imagefd == -1) {
- printf(" Opening disk image failed, errno %d.", errno);
+ perror(" Opening disk image failed");
return 1;
}
break;
case 'l':
logfd = open(optarg, O_RDONLY, 0);
if (logfd == -1) {
- printf(" Opening disk image failed, errno %d.", errno);
+ perror(" Opening log file failed");
return 1;
}
break;
--
2.35.1
Reply to: