msgbuf: Modernize pldm_msgbuf_skip() implementation
The implementation of the other msgbuf APIs follows a pattern that
helps static analysis. Make the implementation of pldm_msgbuf_skip()
consistent, even if it wasn't yet causing dramas.
Change-Id: I5f0486d935935962130a20f3a6564587183fefff
Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
diff --git a/src/msgbuf.h b/src/msgbuf.h
index f953981..b4616b6 100644
--- a/src/msgbuf.h
+++ b/src/msgbuf.h
@@ -1171,16 +1171,17 @@
}
#endif
- if (ctx->remaining < INTMAX_MIN + (intmax_t)count) {
- return -EOVERFLOW;
+ if (ctx->remaining >= (intmax_t)count) {
+ ctx->cursor += count;
+ ctx->remaining -= (intmax_t)count;
+ return 0;
}
- ctx->remaining -= (intmax_t)count;
- if (ctx->remaining < 0) {
- return -EOVERFLOW;
- }
- ctx->cursor += count;
- return 0;
+ if (ctx->remaining >= INTMAX_MIN + (intmax_t)count) {
+ ctx->remaining -= (intmax_t)count;
+ }
+
+ return -EOVERFLOW;
}
/**