summaryrefslogtreecommitdiff
path: root/src/user
diff options
context:
space:
mode:
authordzwdz2022-08-01 21:35:03 +0200
committerdzwdz2022-08-01 21:35:03 +0200
commit5fc7009037e392ccec021b1251ddfff9a8604368 (patch)
tree7a18ffeae1a3842ca6d57c7d83a45654fa7cc17d /src/user
parente9a64093e2187fa858a0bf792d11cb5e7c67064d (diff)
fix some sign comparision warnings
Diffstat (limited to 'src/user')
-rw-r--r--src/user/app/init/driver/ansiterm.c8
-rw-r--r--src/user/lib/file.c2
-rw-r--r--src/user/lib/fs/dir.c7
3 files changed, 11 insertions, 6 deletions
diff --git a/src/user/app/init/driver/ansiterm.c b/src/user/app/init/driver/ansiterm.c
index 7b16537..7d842a5 100644
--- a/src/user/app/init/driver/ansiterm.c
+++ b/src/user/app/init/driver/ansiterm.c
@@ -50,12 +50,12 @@ static void scroll(void) {
cursor.y--;
}
-static void font_blit(int glyph, int x, int y) {
- if (glyph < 0 || glyph >= font.glyph_amt) glyph = 0;
+static void font_blit(size_t glyph, int x, int y) {
+ if (glyph >= font.glyph_amt) glyph = 0;
char *bitmap = font_data + font.glyph_size * glyph;
- for (int i = 0; i < font.w; i++) {
- for (int j = 0; j < font.h; j++) {
+ for (size_t i = 0; i < font.w; i++) {
+ for (size_t j = 0; j < font.h; j++) {
size_t idx = j * font.w + i;
char byte = bitmap[idx / 8];
byte >>= (7-(idx&7));
diff --git a/src/user/lib/file.c b/src/user/lib/file.c
index 05ae2e8..b55a19d 100644
--- a/src/user/lib/file.c
+++ b/src/user/lib/file.c
@@ -151,7 +151,7 @@ size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restri
char *fgets(char *buf, int size, FILE *f) {
char c = '\0';
- size_t pos = 0;
+ long pos = 0;
while (pos < (size-1) && c != '\n' && fread(&c, 1, 1, f))
buf[pos++] = c;
buf[pos++] = '\0';
diff --git a/src/user/lib/fs/dir.c b/src/user/lib/fs/dir.c
index 0529bfe..35028bd 100644
--- a/src/user/lib/fs/dir.c
+++ b/src/user/lib/fs/dir.c
@@ -1,5 +1,6 @@
#include <camellia/syscalls.h>
#include <errno.h>
+#include <limits.h>
#include <string.h>
#include <user/lib/fs/dir.h>
@@ -20,10 +21,14 @@ bool dir_append(struct dirbuild *db, const char *name) {
bool dir_appendl(struct dirbuild *db, const char *name, size_t len) {
if (db->error) return true;
+ if (len > (size_t)LONG_MAX) {
+ db->error = -1;
+ return true;
+ }
len++; // account for the null byte
- if (db->offset < len) {
+ if (db->offset < (long)len) {
name += db->offset;
len -= db->offset;
db->offset = 0;