[SCM] Samba Shared Repository - branch master updated
Amitay Isaacs
amitay at samba.org
Mon Aug 1 09:20:01 UTC 2022
The branch, master has been updated
via 3aecd6e7b50 ctdb-common: CID 1507498: Control flow issues (DEADCODE)
from 7a6bd227989 lib:replace: Remove <sys/mount.h> from filesys.h
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 3aecd6e7b501abfd2c65f8d006a67001f79dd5fc
Author: Martin Schwenke <martin at meltin.net>
Date: Sat Jul 30 10:19:56 2022 +1000
ctdb-common: CID 1507498: Control flow issues (DEADCODE)
Fix typo in error checking. While here adjust the bottom of the
range, making errno 0 invalid.
Add corresponding test cases using an alternative syntax for errno packets
(#nnn[;] - trailing ';' is optional).
Signed-off-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Amitay Isaacs <amitay at gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
Autobuild-Date(master): Mon Aug 1 09:19:55 UTC 2022 on sn-devel-184
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/tmon.c | 2 +-
ctdb/tests/UNIT/cunit/tmon_test_002.sh | 29 +++++++++++++++++++++++++++++
ctdb/tests/src/tmon_test.c | 11 +++++++++++
3 files changed, 41 insertions(+), 1 deletion(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/common/tmon.c b/ctdb/common/tmon.c
index 87a55e3b1e9..04bad1f3bf4 100644
--- a/ctdb/common/tmon.c
+++ b/ctdb/common/tmon.c
@@ -97,7 +97,7 @@ bool tmon_set_exit(struct tmon_pkt *pkt)
bool tmon_set_errno(struct tmon_pkt *pkt, int err)
{
- if (err < 0 && err > UINT16_MAX) {
+ if (err <= 0 || err > UINT16_MAX) {
return false;
}
diff --git a/ctdb/tests/UNIT/cunit/tmon_test_002.sh b/ctdb/tests/UNIT/cunit/tmon_test_002.sh
index 97a17a188e5..e4118a3d09a 100755
--- a/ctdb/tests/UNIT/cunit/tmon_test_002.sh
+++ b/ctdb/tests/UNIT/cunit/tmon_test_002.sh
@@ -4,6 +4,7 @@
epipe=$(errcode EPIPE)
etimedout=$(errcode ETIMEDOUT)
+edom=$(errcode EDOM)
test_cases()
{
@@ -35,6 +36,34 @@ WRITER OK
EOF
unit_test tmon_test "7" false 0 false
+ test_case "errno 110 packet @ 1s, no timeout"
+ ok <<EOF
+READER ERR=110
+WRITER OK
+EOF
+ unit_test tmon_test "#110" false 0 false
+
+ test_case "errno 0 error causes EDOM @ 1s, no timeout"
+ ok <<EOF
+WRITER ERR=$edom
+READER ERR=$epipe
+EOF
+ unit_test tmon_test "#0;" false 0 false
+
+ test_case "errno -1 error causes EDOM @ 1s, no timeout"
+ ok <<EOF
+WRITER ERR=$edom
+READER ERR=$epipe
+EOF
+ unit_test tmon_test "#-1;" false 0 false
+
+ test_case "errno 70000 error causes EDOM @ 1s, no timeout"
+ ok <<EOF
+WRITER ERR=$edom
+READER ERR=$epipe
+EOF
+ unit_test tmon_test "#70000;!0" false 0 false
+
test_case "Exit packet @ 3s, no timeout"
ok <<EOF
READER OK
diff --git a/ctdb/tests/src/tmon_test.c b/ctdb/tests/src/tmon_test.c
index 651c24b7414..fb1f5eb9d30 100644
--- a/ctdb/tests/src/tmon_test.c
+++ b/ctdb/tests/src/tmon_test.c
@@ -45,6 +45,7 @@ static int test_write_callback(void *private_data, struct tmon_pkt *pkt)
private_data, struct test_write_state);
bool status;
size_t len;
+ char *end;
int err;
char c;
const char *t;
@@ -75,6 +76,16 @@ static int test_write_callback(void *private_data, struct tmon_pkt *pkt)
case '!':
status = tmon_set_ping(pkt);
break;
+ case '#':
+ /* Additional errno syntax: #nnn[;] */
+ t = &state->write_data[state->offset];
+ err = (int)strtol(t, &end, 10);
+ state->offset += (end - t);
+ if (state->write_data[state->offset] == ';') {
+ state->offset++;
+ }
+ status = tmon_set_errno(pkt, err);
+ break;
default:
status = false;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list