diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-11-25 17:00:34 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2016-11-25 17:00:34 +0000 |
commit | 7e3722687d94349e08099861bcb9e4f9a3d6b3f5 (patch) | |
tree | 86662aaff1e34b38fa65840e950c02056026c85d /sys/lib | |
parent | 63688857232634445f1801566d1d63cb0c48ce71 (diff) |
Fix signedness warnings with careful casts and replace a re-defined variable.
OK krw@
Diffstat (limited to 'sys/lib')
-rw-r--r-- | sys/lib/libsa/ufs.c | 18 | ||||
-rw-r--r-- | sys/lib/libsa/ufs2.c | 16 |
2 files changed, 17 insertions, 17 deletions
diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c index 2b97c510d7e..e768beaef24 100644 --- a/sys/lib/libsa/ufs.c +++ b/sys/lib/libsa/ufs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs.c,v 1.25 2015/07/17 18:55:00 kspillner Exp $ */ +/* $OpenBSD: ufs.c,v 1.26 2016/11/25 17:00:33 reyk Exp $ */ /* $NetBSD: ufs.c,v 1.16 1996/09/30 16:01:22 ws Exp $ */ /*- @@ -266,7 +266,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p) off = blkoff(fs, fp->f_seekp); file_block = lblkno(fs, fp->f_seekp); - block_size = dblksize(fs, &fp->f_di, file_block); + block_size = dblksize(fs, &fp->f_di, (u_int64_t)file_block); if (file_block != fp->f_buf_blkno) { rc = block_map(f, file_block, &disk_block); @@ -324,7 +324,7 @@ search_directory(char *name, struct open_file *f, ufsino_t *inumber_p) length = strlen(name); fp->f_seekp = 0; - while (fp->f_seekp < fp->f_di.di_size) { + while ((u_int64_t)fp->f_seekp < fp->f_di.di_size) { rc = buf_read_file(f, &buf, &buf_size); if (rc) return (rc); @@ -382,7 +382,8 @@ ufs_open(char *path, struct open_file *f) goto out; if (buf_size != SBSIZE || fs->fs_magic != FS_MAGIC || - fs->fs_bsize > MAXBSIZE || fs->fs_bsize < sizeof(struct fs)) { + (size_t)fs->fs_bsize > MAXBSIZE || + (size_t)fs->fs_bsize < sizeof(struct fs)) { rc = EINVAL; goto out; } @@ -478,15 +479,14 @@ ufs_open(char *path, struct open_file *f) bcopy(cp, &namebuf[link_len], len + 1); - if (link_len < fs->fs_maxsymlinklen) { + if (link_len < (u_int64_t)fs->fs_maxsymlinklen) { bcopy(fp->f_di.di_shortlink, namebuf, link_len); } else { /* * Read file for symbolic link */ - size_t buf_size; daddr32_t disk_block; - struct fs *fs = fp->f_fs; + fs = fp->f_fs; if (!buf) buf = alloc(fs->fs_bsize); @@ -573,7 +573,7 @@ ufs_read(struct open_file *f, void *start, size_t size, size_t *resid) int rc = 0; while (size != 0) { - if (fp->f_seekp >= fp->f_di.di_size) + if ((u_int64_t)fp->f_seekp >= fp->f_di.di_size) break; rc = buf_read_file(f, &buf, &buf_size); @@ -653,7 +653,7 @@ ufs_readdir(struct open_file *f, char *name) fp->f_seekp = 0; else { /* end of dir */ - if (fp->f_seekp >= fp->f_di.di_size) { + if ((u_int64_t)fp->f_seekp >= fp->f_di.di_size) { *name = '\0'; return -1; } diff --git a/sys/lib/libsa/ufs2.c b/sys/lib/libsa/ufs2.c index 8abdb24e681..2e1d945b83b 100644 --- a/sys/lib/libsa/ufs2.c +++ b/sys/lib/libsa/ufs2.c @@ -262,7 +262,7 @@ buf_read_file(struct open_file *f, char **buf_p, size_t *size_p) off = blkoff(fs, fp->f_seekp); file_block = lblkno(fs, fp->f_seekp); - block_size = dblksize(fs, &fp->f_di, file_block); + block_size = dblksize(fs, &fp->f_di, (u_int64_t)file_block); if (file_block != fp->f_buf_blkno) { rc = block_map(f, file_block, &disk_block); @@ -320,7 +320,7 @@ search_directory(char *name, struct open_file *f, ufsino_t *inumber_p) length = strlen(name); fp->f_seekp = 0; - while (fp->f_seekp < fp->f_di.di_size) { + while ((u_int64_t)fp->f_seekp < fp->f_di.di_size) { rc = buf_read_file(f, &buf, &buf_size); if (rc) return (rc); @@ -378,7 +378,8 @@ ufs2_open(char *path, struct open_file *f) goto out; if (buf_size != SBSIZE || fs->fs_magic != FS_UFS2_MAGIC || - fs->fs_bsize > MAXBSIZE || fs->fs_bsize < sizeof(struct fs)) { + (u_int64_t)fs->fs_bsize > MAXBSIZE || + (u_int64_t)fs->fs_bsize < sizeof(struct fs)) { rc = EINVAL; goto out; } @@ -474,15 +475,14 @@ ufs2_open(char *path, struct open_file *f) bcopy(cp, &namebuf[link_len], len + 1); - if (link_len < fs->fs_maxsymlinklen) { + if (link_len < (u_int64_t)fs->fs_maxsymlinklen) { bcopy(fp->f_di.di_shortlink, namebuf, link_len); } else { /* * Read file for symbolic link */ - size_t buf_size; daddr_t disk_block; - struct fs *fs = fp->f_fs; + fs = fp->f_fs; if (!buf) buf = alloc(fs->fs_bsize); @@ -569,7 +569,7 @@ ufs2_read(struct open_file *f, void *start, size_t size, size_t *resid) int rc = 0; while (size != 0) { - if (fp->f_seekp >= fp->f_di.di_size) + if ((u_int64_t)fp->f_seekp >= fp->f_di.di_size) break; rc = buf_read_file(f, &buf, &buf_size); @@ -649,7 +649,7 @@ ufs2_readdir(struct open_file *f, char *name) fp->f_seekp = 0; else { /* end of dir */ - if (fp->f_seekp >= fp->f_di.di_size) { + if ((u_int64_t)fp->f_seekp >= fp->f_di.di_size) { *name = '\0'; return -1; } |