This is an automated email from the git hooks/post-receive script.
teigland pushed a commit to branch master
in repository sanlock.
commit 19575183392dab154ca1b9962189cd666c4576b6
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Dec 12 17:50:58 2023 -0600
sanlock: replace strncat for creating debug output
---
src/paxos_lease.c | 35 ++++++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)
diff --git a/src/paxos_lease.c b/src/paxos_lease.c
index 179d8e7..5643739 100644
--- a/src/paxos_lease.c
+++ b/src/paxos_lease.c
@@ -51,6 +51,35 @@ int get_rand(int a, int b);
#define BK_DEBUG_COUNT 4
#define BK_STR_SIZE 80
+static void bk_debug_append(char *bk_debug, char *bk_str)
+{
+ int off = 0;
+ int i, j;
+
+ /* bk_debug buffer is BK_DEBUG_SIZE, bk_str is BK_STR_SIZE */
+ /* include as much debugging text in bk_debug as will fit */
+
+ for (i = 0; i < BK_DEBUG_SIZE - 1; i++) {
+ if (!bk_debug[i]) {
+ off = i;
+ break;
+ }
+ }
+
+ if (off >= (BK_DEBUG_SIZE-1)) {
+ bk_debug[BK_DEBUG_SIZE-1] = '\0';
+ return;
+ }
+
+ for (j = 0; j < strlen(bk_str); j++) {
+ bk_debug[off++] = bk_str[j];
+ if (off >= BK_DEBUG_SIZE) {
+ bk_debug[BK_DEBUG_SIZE-1] = '\0';
+ return;
+ }
+ }
+}
+
static uint32_t roundup_power_of_two(uint32_t val)
{
val--;
@@ -577,7 +606,7 @@ static int run_ballot(struct task *task, struct token *token, uint32_t
flags,
(unsigned long long)bk_in.lver,
bk_in.flags);
bk_str[BK_STR_SIZE-1] = '\0';
- strncat(bk_debug, bk_str, BK_STR_SIZE-1);
+ bk_debug_append(bk_debug, bk_str);
bk_debug_count++;
}
@@ -790,7 +819,7 @@ static int run_ballot(struct task *task, struct token *token, uint32_t
flags,
(unsigned long long)bk->lver,
bk->flags);
bk_str[BK_STR_SIZE-1] = '\0';
- strncat(bk_debug, bk_str, BK_STR_SIZE-1);
+ bk_debug_append(bk_debug, bk_str);
bk_debug_count++;
}
@@ -1407,7 +1436,7 @@ static int _lease_read_one(struct task *task,
(unsigned long long)bk.lver,
bk.flags);
bk_str[BK_STR_SIZE-1] = '\0';
- strncat(bk_debug, bk_str, BK_STR_SIZE-1);
+ bk_debug_append(bk_debug, bk_str);
bk_debug_count++;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
Show replies by thread