summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorRay Lai <ray@cvs.openbsd.org>2006-08-02 03:28:51 +0000
committerRay Lai <ray@cvs.openbsd.org>2006-08-02 03:28:51 +0000
commite557c339cdc3678c69db3ff3bba215d5ba737ce1 (patch)
treeeaed26cc13f6a823e199a008d19950afd5ba4fdc /usr.bin
parent1801a36e7d92e0d3d516ebc46bcd1d170892056a (diff)
rcs_buf_set(), rcs_buf_append, and rcs_buf_fappend should not return
ssize_t. The return values aren't usually checked anyway. Also remove unnecessary casts and improve type usage. OK xsa@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rcs/buf.c17
-rw-r--r--usr.bin/rcs/buf.h8
2 files changed, 13 insertions, 12 deletions
diff --git a/usr.bin/rcs/buf.c b/usr.bin/rcs/buf.c
index e4bb81040fd..525f7000c01 100644
--- a/usr.bin/rcs/buf.c
+++ b/usr.bin/rcs/buf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.c,v 1.6 2006/07/08 09:25:44 ray Exp $ */
+/* $OpenBSD: buf.c,v 1.7 2006/08/02 03:28:50 ray Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -178,7 +178,7 @@ rcs_buf_empty(BUF *b)
* bytes of data found at <src>. If the buffer was not created with
* BUF_AUTOEXT, as many bytes as possible will be copied in the buffer.
*/
-ssize_t
+size_t
rcs_buf_set(BUF *b, const void *src, size_t len, size_t off)
{
size_t rlen = 0;
@@ -251,7 +251,7 @@ rcs_buf_getc(BUF *b, size_t pos)
* will get resized to an appropriate size to accept all data.
* Returns the number of bytes successfully appended to the buffer.
*/
-ssize_t
+size_t
rcs_buf_append(BUF *b, const void *data, size_t len)
{
size_t left, rlen;
@@ -280,21 +280,22 @@ rcs_buf_append(BUF *b, const void *data, size_t len)
* rcs_buf_fappend()
*
*/
-ssize_t
+size_t
rcs_buf_fappend(BUF *b, const char *fmt, ...)
{
- ssize_t ret;
+ size_t ret;
+ int n;
char *str;
va_list vap;
va_start(vap, fmt);
- ret = vasprintf(&str, fmt, vap);
+ n = vasprintf(&str, fmt, vap);
va_end(vap);
- if (ret == -1)
+ if (n == -1)
errx(1, "rcs_buf_fappend: failed to format data");
- ret = rcs_buf_append(b, str, (size_t)ret);
+ ret = rcs_buf_append(b, str, n);
xfree(str);
return (ret);
}
diff --git a/usr.bin/rcs/buf.h b/usr.bin/rcs/buf.h
index 197118441fa..5e2ffc9224e 100644
--- a/usr.bin/rcs/buf.h
+++ b/usr.bin/rcs/buf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: buf.h,v 1.4 2006/07/08 09:25:44 ray Exp $ */
+/* $OpenBSD: buf.h,v 1.5 2006/08/02 03:28:50 ray Exp $ */
/*
* Copyright (c) 2003 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -49,9 +49,9 @@ void rcs_buf_free(BUF *);
void *rcs_buf_release(BUF *);
u_char rcs_buf_getc(BUF *, size_t);
void rcs_buf_empty(BUF *);
-ssize_t rcs_buf_set(BUF *, const void *, size_t, size_t);
-ssize_t rcs_buf_append(BUF *, const void *, size_t);
-ssize_t rcs_buf_fappend(BUF *, const char *, ...)
+size_t rcs_buf_set(BUF *, const void *, size_t, size_t);
+size_t rcs_buf_append(BUF *, const void *, size_t);
+size_t rcs_buf_fappend(BUF *, const char *, ...)
__attribute__((format(printf, 2, 3)));
void rcs_buf_putc(BUF *, int);
size_t rcs_buf_len(BUF *);