From 4ff107e46f9fc698d8f5c4ebe98280f74a45f970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BA=90=E6=96=87=E9=9B=A8?= <41315874+fumiama@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:22:57 +0900 Subject: [PATCH] chore: optimize documents --- base16384.h | 2 +- test/file_test.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/base16384.h b/base16384.h index 288380e..e0631a8 100644 --- a/base16384.h +++ b/base16384.h @@ -78,7 +78,7 @@ typedef ssize_t(*base16384_reader_t)(const void *client_data, void *buffer, size typedef ssize_t(*base16384_writer_t)(const void *client_data, const void *buffer, size_t count); struct base16384_stream_t { - union { + const union { base16384_reader_t reader; base16384_writer_t writer; } f; diff --git a/test/file_test.h b/test/file_test.h index 06f6745..b44fe8b 100644 --- a/test/file_test.h +++ b/test/file_test.h @@ -100,7 +100,8 @@ static ssize_t base16384_test_file_reader(const void *client_data, void *buffer, int fd = (int)((uintptr_t)client_data); ssize_t ret = read(fd, buffer, count); if(ret < 0) return ret; - for(ssize_t i = 0; i < ret; i++) { + ssize_t i; + for(i = 0; i < ret; i++) { ((uint8_t*)(buffer))[i] = ~((uint8_t*)(buffer))[i]; } return ret; @@ -114,7 +115,8 @@ static ssize_t base16384_test_file_writer(const void *client_data, const void *b } uint8_t* wbuf = (uint8_t*)malloc(count); if(!wbuf) return -200; - for(ssize_t i = 0; i < count; i++) { + ssize_t i; + for(i = 0; i < count; i++) { wbuf[i] = ~((uint8_t*)(buffer))[i]; } ssize_t ret = write(fd, buffer, count);