aboutsummaryrefslogtreecommitdiff
path: root/toys/other
diff options
context:
space:
mode:
Diffstat (limited to 'toys/other')
-rw-r--r--toys/other/rev.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/toys/other/rev.c b/toys/other/rev.c
index 4cf7214f..15066310 100644
--- a/toys/other/rev.c
+++ b/toys/other/rev.c
@@ -20,11 +20,11 @@ static void do_rev(int fd, char *name)
char *c;
for (;;) {
- int len, i;
+ unsigned len, i;
if (!(c = get_line(fd))) break;
- len = strlen(c) - 1;
- for (i = 0; i <= len/2; i++) {
+ len = strlen(c);
+ if (len--) for (i = 0; i <= len/2; i++) {
char tmp = c[i];
c[i] = c[len-i];