Return int from internal sbuf_len function

This silences lots of warnings where the result is implicitly
converted to `int`
This commit is contained in:
Peter Hill 2023-10-26 15:19:26 +01:00
parent 0c6fd78251
commit 35ddd9ec01
No known key found for this signature in database
GPG Key ID: 0C6B9742E72848EE
2 changed files with 5 additions and 4 deletions

View File

@ -11,6 +11,7 @@
#include "config.h" #include "config.h"
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -203,7 +204,7 @@ sbuf_catb(safebuf_t *s1, const safebuf_t *s2) {
size_t res; size_t res;
assert(SAFEBUF_CHECK(s1)); assert(SAFEBUF_CHECK(s1));
assert(SAFEBUF_CHECK(s2)); assert(SAFEBUF_CHECK(s2));
s2len = sbuf_len(s2); s2len = (size_t)sbuf_len(s2);
sbuf_grow(s1, 1 + s1->cl + s2len); sbuf_grow(s1, 1 + s1->cl + s2len);
res = strlcat(s1->buf + s1->cl, s2->buf, s1->len - s1->cl); res = strlcat(s1->buf + s1->cl, s2->buf, s1->len - s1->cl);
assert( res < s1->len ); assert( res < s1->len );
@ -212,10 +213,10 @@ sbuf_catb(safebuf_t *s1, const safebuf_t *s2) {
} }
/* Return length of string in sbuf */ /* Return length of string in sbuf */
size_t int
sbuf_len(const safebuf_t *sb) { sbuf_len(const safebuf_t *sb) {
assert(SAFEBUF_CHECK(sb)); assert(SAFEBUF_CHECK(sb));
return sb->cl; return (int)sb->cl;
} }
/* Return C string in an sbuf */ /* Return C string in an sbuf */

View File

@ -99,7 +99,7 @@ void sbuf_cat(safebuf_t *sbuf, const char *s2);
void sbuf_catb(safebuf_t *s1, const safebuf_t *s2); void sbuf_catb(safebuf_t *s1, const safebuf_t *s2);
/* Return length of the string in sbuf */ /* Return length of the string in sbuf */
size_t sbuf_len(const safebuf_t *sbuf); int sbuf_len(const safebuf_t *sbuf);
/* Return the C string inside an sbuf */ /* Return the C string inside an sbuf */
char *sbuf_str(const safebuf_t *sbuf); char *sbuf_str(const safebuf_t *sbuf);