The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=68160fbd1f1f727173932ae6189ca7b5f7ebe68c

commit 68160fbd1f1f727173932ae6189ca7b5f7ebe68c
Author:     Alfonso <[email protected]>
AuthorDate: 2023-02-27 23:19:54 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2023-02-27 23:26:49 +0000

    stand: Minor cleanup
    
    Replace a cast '0' for a null pointers with NULL
    Replace a 'goto loop' with a do-while loop in ufs and ext2fs.
    Cast cp pointer to uintptr_t to test to see if it's aligned rather than 
long.
    
    [ minor tweaks based on my & hps' review, reworded commit message ]
    Reviewed by: imp, hps
    Pull Request: https://github.com/freebsd/freebsd-src/pull/547
---
 stand/libsa/ext2fs.c   | 26 ++++++++++++++------------
 stand/libsa/in_cksum.c |  2 +-
 stand/libsa/ufs.c      | 23 ++++++++++++-----------
 3 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/stand/libsa/ext2fs.c b/stand/libsa/ext2fs.c
index 3e91d9fd516f..043da159f0ee 100644
--- a/stand/libsa/ext2fs.c
+++ b/stand/libsa/ext2fs.c
@@ -796,10 +796,11 @@ ext2fs_close(struct open_file *f)
        struct file *fp = (struct file *)f->f_fsdata;
        int level;
 
-       f->f_fsdata = (void *)0;
-       if (fp == (struct file *)0)
+       if (fp == NULL)
                return (0);
 
+       f->f_fsdata = NULL;
+
        for (level = 0; level < EXT2_NIADDR; level++) {
                if (fp->f_blk[level])
                        free(fp->f_blk[level]);
@@ -891,16 +892,17 @@ ext2fs_readdir(struct open_file *f, struct dirent *d)
        /*
         * assume that a directory entry will not be split across blocks
         */
-again:
-       if (fp->f_seekp >= fp->f_di.di_size)
-               return (ENOENT);
-       error = buf_read_file(f, &buf, &buf_size);
-       if (error)
-               return (error);
-       ed = (struct ext2dirent *)buf;
-       fp->f_seekp += ed->d_reclen;
-       if (ed->d_ino == (ino_t)0)
-               goto again;
+
+       do {
+               if (fp->f_seekp >= fp->f_di.di_size)
+                       return (ENOENT);
+               error = buf_read_file(f, &buf, &buf_size);
+               if (error)
+                       return (error);
+               ed = (struct ext2dirent *)buf;
+               fp->f_seekp += ed->d_reclen;
+       } while (ed->d_ino == (ino_t)0);
+
        d->d_type = EXTFTODT(ed->d_type);
        strncpy(d->d_name, ed->d_name, ed->d_namlen);
        d->d_name[ed->d_namlen] = '\0';
diff --git a/stand/libsa/in_cksum.c b/stand/libsa/in_cksum.c
index 2f8c448fc0eb..590a304271d0 100644
--- a/stand/libsa/in_cksum.c
+++ b/stand/libsa/in_cksum.c
@@ -61,7 +61,7 @@ in_cksum(void *p, int len)
                        sum += v + *cp++;
                        len--;
                }
-               if (((long)cp & 1) == 0) {
+               if (((uintptr_t)cp & 1) == 0) {
                        while ((len -= 2) >= 0) {
                                sum += *(u_short *)cp;
                                cp += 2;
diff --git a/stand/libsa/ufs.c b/stand/libsa/ufs.c
index 769fe9120ee6..cb4c7ca6453c 100644
--- a/stand/libsa/ufs.c
+++ b/stand/libsa/ufs.c
@@ -409,7 +409,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t 
*size_p)
        block_size = sblksize(fs, DIP(fp, di_size), file_block);
 
        if (file_block != fp->f_buf_blkno) {
-               if (fp->f_buf == (char *)0)
+               if (fp->f_buf == NULL)
                        fp->f_buf = malloc(fs->fs_bsize);
 
                rc = block_map(f, file_block, &disk_block);
@@ -888,16 +888,17 @@ ufs_readdir(struct open_file *f, struct dirent *d)
        /*
         * assume that a directory entry will not be split across blocks
         */
-again:
-       if (fp->f_seekp >= DIP(fp, di_size))
-               return (ENOENT);
-       error = buf_read_file(f, &buf, &buf_size);
-       if (error)
-               return (error);
-       dp = (struct direct *)buf;
-       fp->f_seekp += dp->d_reclen;
-       if (dp->d_ino == (ino_t)0)
-               goto again;
+
+       do {
+               if (fp->f_seekp >= DIP(fp, di_size))
+                       return (ENOENT);
+               error = buf_read_file(f, &buf, &buf_size);
+               if (error)
+                       return (error);
+               dp = (struct direct *)buf;
+               fp->f_seekp += dp->d_reclen;
+       } while (dp->d_ino == (ino_t)0);
+
        d->d_type = dp->d_type;
        strcpy(d->d_name, dp->d_name);
        return (0);

Reply via email to