summaryrefslogtreecommitdiff
path: root/libmisc
diff options
context:
space:
mode:
Diffstat (limited to 'libmisc')
-rw-r--r--libmisc/include/libmisc/assert.h3
-rw-r--r--libmisc/tests/test_obj_autobox.c10
-rw-r--r--libmisc/tests/test_obj_nest.c10
3 files changed, 13 insertions, 10 deletions
diff --git a/libmisc/include/libmisc/assert.h b/libmisc/include/libmisc/assert.h
index ccdb288..18ca2e5 100644
--- a/libmisc/include/libmisc/assert.h
+++ b/libmisc/include/libmisc/assert.h
@@ -12,7 +12,10 @@
#else
# define __assert_msg(expr, expr_str, msg) \
do { \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wtype-limits\"") \
if (!(expr)) \
+ _Pragma("GCC diagnostic pop") \
__assert_msg_fail(expr_str, __FILE__, __LINE__, __func__, msg); \
} while (0)
[[noreturn]] void __assert_msg_fail(const char *expr,
diff --git a/libmisc/tests/test_obj_autobox.c b/libmisc/tests/test_obj_autobox.c
index 1bf442d..1110639 100644
--- a/libmisc/tests/test_obj_autobox.c
+++ b/libmisc/tests/test_obj_autobox.c
@@ -14,11 +14,11 @@
/* interfaces *****************************************************************/
#define reader_LO_IFACE \
- LO_FUNC(ssize_t, read, void *, size_t)
+ LO_FUNC(size_t, read, void *, size_t)
LO_INTERFACE(reader);
#define writer_LO_IFACE \
- LO_FUNC(ssize_t, write, void *, size_t)
+ LO_FUNC(size_t, write, void *, size_t)
LO_INTERFACE(writer);
#define read_writer_LO_IFACE \
@@ -42,7 +42,7 @@ LO_IMPLEMENTATION_C(reader, struct myclass, myclass, static);
LO_IMPLEMENTATION_C(writer, struct myclass, myclass, static);
LO_IMPLEMENTATION_C(read_writer, struct myclass, myclass, static);
-static ssize_t myclass_read(struct myclass *self, void *buf, size_t count) {
+static size_t myclass_read(struct myclass *self, void *buf, size_t count) {
test_assert(self);
if (count > self->len)
count = self->len;
@@ -50,10 +50,10 @@ static ssize_t myclass_read(struct myclass *self, void *buf, size_t count) {
return count;
}
-static ssize_t myclass_write(struct myclass *self, void *buf, size_t count) {
+static size_t myclass_write(struct myclass *self, void *buf, size_t count) {
test_assert(self);
if (self->len)
- return -1;
+ return 0;
if (count > sizeof(self->buf))
count = sizeof(self->buf);
memcpy(self->buf, buf, count);
diff --git a/libmisc/tests/test_obj_nest.c b/libmisc/tests/test_obj_nest.c
index 66c1efd..20ffe4a 100644
--- a/libmisc/tests/test_obj_nest.c
+++ b/libmisc/tests/test_obj_nest.c
@@ -13,11 +13,11 @@
/* interfaces *****************************************************************/
#define reader_LO_IFACE \
- LO_FUNC(ssize_t, read, void *, size_t)
+ LO_FUNC(size_t, read, void *, size_t)
LO_INTERFACE(reader);
#define writer_LO_IFACE \
- LO_FUNC(ssize_t, write, void *, size_t)
+ LO_FUNC(size_t, write, void *, size_t)
LO_INTERFACE(writer);
#define read_writer_LO_IFACE \
@@ -41,7 +41,7 @@ LO_IMPLEMENTATION_C(reader, struct myclass, myclass, static);
LO_IMPLEMENTATION_C(writer, struct myclass, myclass, static);
LO_IMPLEMENTATION_C(read_writer, struct myclass, myclass, static);
-static ssize_t myclass_read(struct myclass *self, void *buf, size_t count) {
+static size_t myclass_read(struct myclass *self, void *buf, size_t count) {
test_assert(self);
if (count > self->len)
count = self->len;
@@ -49,10 +49,10 @@ static ssize_t myclass_read(struct myclass *self, void *buf, size_t count) {
return count;
}
-static ssize_t myclass_write(struct myclass *self, void *buf, size_t count) {
+static size_t myclass_write(struct myclass *self, void *buf, size_t count) {
test_assert(self);
if (self->len)
- return -1;
+ return 0;
if (count > sizeof(self->buf))
count = sizeof(self->buf);
memcpy(self->buf, buf, count);