summaryrefslogtreecommitdiff
path: root/upb/bytestream.c
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2011-08-27 18:44:37 -0700
committerJoshua Haberman <jhaberman@gmail.com>2011-08-27 18:44:37 -0700
commit48fedab345674000dd2f8dd4d8356ee995d9263e (patch)
treeba5faf3637e6963d45168f1e532ac3c9734569c0 /upb/bytestream.c
parentc03802b0f18a1a654f832ddff01a5bd78efbc4d6 (diff)
Add packed field support (untested).
Diffstat (limited to 'upb/bytestream.c')
-rw-r--r--upb/bytestream.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/upb/bytestream.c b/upb/bytestream.c
index 976b139..dc2fa61 100644
--- a/upb/bytestream.c
+++ b/upb/bytestream.c
@@ -66,12 +66,12 @@ size_t upb_stdio_fetch(void *src, uint64_t ofs, upb_status *s) {
size_t read = fread(&buf->data, 1, BUF_SIZE, stdio->file);
if(read < (size_t)BUF_SIZE) {
// Error or EOF.
- if(feof(stdio->file)) {
- upb_status_setf(s, UPB_EOF, "");
- } else if(ferror(stdio->file)) {
+ if(feof(stdio->file)) return 0;
+ if(ferror(stdio->file)) {
upb_status_fromerrno(s);
- return 0;
+ return -1;
}
+ assert(false);
}
buf->len = read;
return buf->ofs + buf->len;
@@ -190,9 +190,8 @@ upb_bytesink* upb_stdio_bytesink(upb_stdio *stdio) { return &stdio->sink; }
size_t upb_stringsrc_fetch(void *_src, uint64_t ofs, upb_status *s) {
upb_stringsrc *src = _src;
- size_t bytes = src->len - ofs;
- if (bytes == 0) s->code = UPB_EOF;
- return bytes;
+ (void)s; // No errors can occur.
+ return src->len - ofs;
}
void upb_stringsrc_read(void *_src, uint64_t src_ofs, size_t len, char *dst) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback