The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=568be71de3b44c8c4679e4c202a782a7302426ed

commit 568be71de3b44c8c4679e4c202a782a7302426ed
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2024-05-25 16:52:32 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2024-05-27 15:26:47 +0000

    stress2: Use the proper type for the getopt(3) return value
    
    On arm platforms "char" is typically unsigned, in which case the test
    "(c = getopt(...)) != -1" does not behave as desired.
    
    Reviewed by:    pho
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D45365
---
 tools/test/stress2/tools/flip.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/test/stress2/tools/flip.c b/tools/test/stress2/tools/flip.c
index cdc2742de59f..f2a4d86e115b 100644
--- a/tools/test/stress2/tools/flip.c
+++ b/tools/test/stress2/tools/flip.c
@@ -85,8 +85,7 @@ main(int argc, char *argv[])
        struct stat st;
        off_t pos;
        size_t size;
-       int fd, i, times;
-       char c;
+       int c, fd, i, times;
 
        times = 1;
        size = 0;
@@ -126,18 +125,20 @@ main(int argc, char *argv[])
        }
 
        for (i = 0; i < times; i++) {
+               char ch;
+
                pos = arc4random() % size;
                if (lseek(fd, pos, SEEK_SET) == -1)
                        err(1, "lseek()");
-               if (read(fd, &c, 1) != 1)
+               if (read(fd, &ch, 1) != 1)
                        err(1, "read()");
                if (arc4random() % 100 < 98)
-                       flip(&c, 1);
+                       flip(&ch, 1);
                else
-                       trash(&c);
+                       trash(&ch);
                if (lseek(fd, pos, SEEK_SET) == -1)
                        err(1, "lseek()");
-               if (write(fd, &c, 1) != 1)
+               if (write(fd, &ch, 1) != 1)
                        err(1, "write()");
        }
 

Reply via email to