summaryrefslogtreecommitdiff
path: root/libmisc/tests/test_obj_nest.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmisc/tests/test_obj_nest.c')
-rw-r--r--libmisc/tests/test_obj_nest.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/libmisc/tests/test_obj_nest.c b/libmisc/tests/test_obj_nest.c
index bb9d6de..be303f2 100644
--- a/libmisc/tests/test_obj_nest.c
+++ b/libmisc/tests/test_obj_nest.c
@@ -5,6 +5,10 @@
*/
#include <string.h> /* for memcpy() */
+#include <limits.h> /* for SSIZE_MAX, not set by newlib */
+#ifndef SSIZE_MAX
+#define SSIZE_MAX (SIZE_MAX >> 1)
+#endif
#include <libmisc/obj.h>
@@ -45,8 +49,10 @@ static ssize_t myclass_read(struct myclass *self, void *buf, size_t count) {
test_assert(self);
if (count > self->len)
count = self->len;
+ if (count > SSIZE_MAX)
+ count = SSIZE_MAX;
memcpy(buf, self->buf, count);
- return count;
+ return (ssize_t)count;
}
static ssize_t myclass_write(struct myclass *self, void *buf, size_t count) {
@@ -55,9 +61,11 @@ static ssize_t myclass_write(struct myclass *self, void *buf, size_t count) {
return -1;
if (count > sizeof(self->buf))
count = sizeof(self->buf);
+ if (count > SSIZE_MAX)
+ count = SSIZE_MAX;
memcpy(self->buf, buf, count);
self->len = count;
- return count;
+ return (ssize_t)count;
}
/* main test body *************************************************************/