[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/7] libps: fix some signed vs unsigned comparision
From: |
Etienne Brateau |
Subject: |
[PATCH 5/7] libps: fix some signed vs unsigned comparision |
Date: |
Wed, 19 Jan 2022 20:29:43 +0100 |
---
libps/proclist.c | 2 +-
libps/write.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/libps/proclist.c b/libps/proclist.c
index 4e2174ac..c9ceaf0a 100644
--- a/libps/proclist.c
+++ b/libps/proclist.c
@@ -120,7 +120,7 @@ proc_stat_list_add_pids (struct proc_stat_list *pp,
return err;
else
{
- int i;
+ unsigned i;
struct proc_stat **end = pp->proc_stats + pp->num_procs;
if (proc_stats)
diff --git a/libps/write.c b/libps/write.c
index 1f7f52cc..21d0a7a8 100644
--- a/libps/write.c
+++ b/libps/write.c
@@ -43,7 +43,7 @@ flush (const char **beg, const char *new, FILE *s)
{
size_t len = new - 1 - b;
int ret = fwrite (b, 1, len, s);
- if (ret < len)
+ if (ret < 0 || (size_t) ret < len)
return 1;
}
return 0;
@@ -58,7 +58,7 @@ noise_write (const char *t, ssize_t max, FILE *s)
const char *ok = t;
size_t len = 0;
- while ((ch = *t++) && (max < 0 || len < max))
+ while ((ch = *t++) && (max < 0 || len < (size_t) max))
if (isgraph (ch) || ch == ' ')
len++;
else
@@ -69,7 +69,7 @@ noise_write (const char *t, ssize_t max, FILE *s)
return errno;
len += (is_cntl ? 2 : 4);
- if (max >= 0 && len > max)
+ if (max >= 0 && len > (size_t) max)
break;
if (is_cntl)
@@ -97,7 +97,7 @@ noise_len (const char *t, ssize_t max)
else
{
size_t rep_len = iscntl (ch) ? 2 : 4;
- if (max >= 0 && rep_len + len > max)
+ if (max >= 0 && rep_len + len > (size_t) max)
break;
len += rep_len;
}
--
2.34.1
- [PATCH 2/7] libpager: fix assertion unsigned against 0, (continued)
- [PATCH 2/7] libpager: fix assertion unsigned against 0, Etienne Brateau, 2022/01/19
- [PATCH 3/7] libstore: fix type of a counter, Etienne Brateau, 2022/01/19
- [PATCH 4/7] libdiskfs: improve asserts and remove a sign compare warning, Etienne Brateau, 2022/01/19
- [PATCH 7/7] proc: Fix variable type, Etienne Brateau, 2022/01/19
- [PATCH 6/7] libnetfs: fix type of variable, Etienne Brateau, 2022/01/19
- [PATCH 5/7] libps: fix some signed vs unsigned comparision,
Etienne Brateau <=
- Re: [PATCH 1/7] libpager: fix a comparision between signed and unsigned, Samuel Thibault, 2022/01/19