From 4422124e096a80da3d585d831fee136149c36b0d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 18 May 2017 10:37:30 +0200 Subject: [PATCH] g_lock: Move parsing routines together No code change, just shuffling around: Before this patchset, g_lock_parse was somewhere in the middle. This carries no real logic, put it on top. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/lib/g_lock.c | 108 +++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c index d0d835cdbad..542abe4f24f 100644 --- a/source3/lib/g_lock.c +++ b/source3/lib/g_lock.c @@ -61,6 +61,60 @@ static void g_lock_rec_get(struct g_lock_rec *rec, server_id_get(&rec->pid, buf+1); } +static ssize_t g_lock_put(uint8_t *buf, size_t buflen, + const struct g_lock_rec *locks, + size_t num_locks) +{ + size_t i, len, ofs; + + if (num_locks > UINT32_MAX/G_LOCK_REC_LENGTH) { + return -1; + } + + len = num_locks * G_LOCK_REC_LENGTH; + + if (len > buflen) { + return len; + } + + ofs = 0; + + for (i=0; i UINT32_MAX/G_LOCK_REC_LENGTH) { - return -1; - } - - len = num_locks * G_LOCK_REC_LENGTH; - - if (len > buflen) { - return len; - } - - ofs = 0; - - for (i=0; i