Next, use NULL instead of casting 0 to pointer types. Index: sys/lib/libsa/ufs.c =================================================================== RCS file: /work/cvsroot/src/sys/lib/libsa/ufs.c,v retrieving revision 1.22 diff -p -u -r1.22 ufs.c --- sys/lib/libsa/ufs.c 30 May 2013 19:19:09 -0000 1.22 +++ sys/lib/libsa/ufs.c 22 Jul 2014 17:43:12 -0000 @@ -221,7 +221,7 @@ block_map(struct open_file *f, daddr32_t } if (fp->f_blkno[level] != ind_block_num) { - if (fp->f_blk[level] == (char *)0) + if (fp->f_blk[level] == NULL) fp->f_blk[level] = alloc(fs->fs_bsize); twiddle(); @@ -273,7 +273,7 @@ buf_read_file(struct open_file *f, char if (rc) return (rc); - if (fp->f_buf == (char *)0) + if (fp->f_buf == NULL) fp->f_buf = alloc(fs->fs_bsize); if (disk_block == 0) { @@ -538,8 +538,8 @@ ufs_close(struct open_file *f) { struct file *fp = (struct file *)f->f_fsdata; - f->f_fsdata = (void *)0; - if (fp == (struct file *)0) + f->f_fsdata = NULL; + if (fp == NULL) return (0); return (ufs_close_internal(fp)); Index: sys/lib/libsa/ufs2.c =================================================================== RCS file: /work/cvsroot/src/sys/lib/libsa/ufs2.c,v retrieving revision 1.2 diff -p -u -r1.2 ufs2.c --- sys/lib/libsa/ufs2.c 29 Apr 2014 07:52:06 -0000 1.2 +++ sys/lib/libsa/ufs2.c 22 Jul 2014 17:45:58 -0000 @@ -217,7 +217,7 @@ block_map(struct open_file *f, daddr_t f } if (fp->f_blkno[level] != ind_block_num) { - if (fp->f_blk[level] == (char *)0) + if (fp->f_blk[level] == NULL) fp->f_blk[level] = alloc(fs->fs_bsize); twiddle(); @@ -269,7 +269,7 @@ buf_read_file(struct open_file *f, char if (rc) return (rc); - if (fp->f_buf == (char *)0) + if (fp->f_buf == NULL) fp->f_buf = alloc(fs->fs_bsize); if (disk_block == 0) { @@ -534,8 +534,8 @@ ufs2_close(struct open_file *f) { struct file *fp = (struct file *)f->f_fsdata; - f->f_fsdata = (void *)0; - if (fp == (struct file *)0) + f->f_fsdata = NULL; + if (fp == NULL) return (0); return (ufs2_close_internal(fp));
On Tue, Jul 22, 2014 at 09:54:03AM -0500, Kent R. Spillner wrote: > Sorry, let me split this into smaller diffs to ease review. > > First up, the diff below removes a redundant cast: buf is declared a > char * so there's no need to cast it to a char *. I noticed the same > issue in ufs.c, too, so fix it in both places. > > Index: ufs.c > =================================================================== > RCS file: /work/cvsroot/src/sys/lib/libsa/ufs.c,v > retrieving revision 1.22 > diff -p -u -r1.22 ufs.c > --- ufs.c 30 May 2013 19:19:09 -0000 1.22 > +++ ufs.c 21 Jul 2014 22:30:32 -0000 > @@ -502,7 +502,7 @@ ufs_open(char *path, struct open_file *f > if (rc) > goto out; > > - bcopy((char *)buf, namebuf, (unsigned)link_len); > + bcopy(buf, namebuf, (unsigned)link_len); > } > > /* > Index: ufs2.c > =================================================================== > RCS file: /work/cvsroot/src/sys/lib/libsa/ufs2.c,v > retrieving revision 1.2 > diff -p -u -r1.2 ufs2.c > --- ufs2.c 29 Apr 2014 07:52:06 -0000 1.2 > +++ ufs2.c 21 Jul 2014 22:30:48 -0000 > @@ -498,7 +498,7 @@ ufs2_open(char *path, struct open_file * > if (rc) > goto out; > > - bcopy((char *)buf, namebuf, (unsigned)link_len); > + bcopy(buf, namebuf, (unsigned)link_len); > } > > /* > > > > On Wed, Jul 16, 2014 at 05:55:55PM -0500, Kent R. Spillner wrote: > > *Bump* > > > > > On Jul 10, 2014, at 12:33, "Kent R. Spillner" <kspill...@acm.org> wrote: > > > > > > Ping. > > > > > >> On Thu, May 01, 2014 at 01:22:56PM -0500, Kent R. Spillner wrote: > > >> After sending my previous reply I noticed that you already committed > > >> your diff, so here are my comments again in the form of a proper diff: > > >> > > >> * Use NULL instead of casting 0 to pointer types > > >> > > >> * Remove unnecessary (char *) cast on buf because buf was already > > >> declared as char * > > >> > > >> * Simplify "if ((rc = ...) != 0)" idiom to equivalent "if ((rc = ...))" > > >> > > >> > > >> Index: sys/lib/libsa/ufs2.c > > >> =================================================================== > > >> RCS file: /work/cvsroot/src/sys/lib/libsa/ufs2.c,v > > >> retrieving revision 1.2 > > >> diff -p -u -r1.2 ufs2.c > > >> --- sys/lib/libsa/ufs2.c 29 Apr 2014 07:52:06 -0000 1.2 > > >> +++ sys/lib/libsa/ufs2.c 1 May 2014 16:54:25 -0000 > > >> @@ -217,7 +217,7 @@ block_map(struct open_file *f, daddr_t f > > >> } > > >> > > >> if (fp->f_blkno[level] != ind_block_num) { > > >> - if (fp->f_blk[level] == (char *)0) > > >> + if (fp->f_blk[level] == NULL) > > >> fp->f_blk[level] = > > >> alloc(fs->fs_bsize); > > >> twiddle(); > > >> @@ -269,7 +269,7 @@ buf_read_file(struct open_file *f, char > > >> if (rc) > > >> return (rc); > > >> > > >> - if (fp->f_buf == (char *)0) > > >> + if (fp->f_buf == NULL) > > >> fp->f_buf = alloc(fs->fs_bsize); > > >> > > >> if (disk_block == 0) { > > >> @@ -401,7 +401,7 @@ ufs2_open(char *path, struct open_file * > > >> } > > >> > > >> inumber = ROOTINO; > > >> - if ((rc = read_inode(inumber, f)) != 0) > > >> + if ((rc = read_inode(inumber, f))) > > >> goto out; > > >> > > >> cp = path; > > >> @@ -454,7 +454,7 @@ ufs2_open(char *path, struct open_file * > > >> /* > > >> * Open next component. > > >> */ > > >> - if ((rc = read_inode(inumber, f)) != 0) > > >> + if ((rc = read_inode(inumber, f))) > > >> goto out; > > >> > > >> /* > > >> @@ -498,7 +498,7 @@ ufs2_open(char *path, struct open_file * > > >> if (rc) > > >> goto out; > > >> > > >> - bcopy((char *)buf, namebuf, (unsigned)link_len); > > >> + bcopy(buf, namebuf, (unsigned)link_len); > > >> } > > >> > > >> /* > > >> @@ -511,7 +511,7 @@ ufs2_open(char *path, struct open_file * > > >> else > > >> inumber = ROOTINO; > > >> > > >> - if ((rc = read_inode(inumber, f)) != 0) > > >> + if ((rc = read_inode(inumber, f))) > > >> goto out; > > >> } > > >> } > > >> @@ -534,8 +534,8 @@ ufs2_close(struct open_file *f) > > >> { > > >> struct file *fp = (struct file *)f->f_fsdata; > > >> > > >> - f->f_fsdata = (void *)0; > > >> - if (fp == (struct file *)0) > > >> + f->f_fsdata = NULL; > > >> + if (fp == NULL) > > >> return (0); > > >> > > >> return (ufs2_close_internal(fp)); > > >> @@ -656,7 +656,7 @@ ufs2_readdir(struct open_file *f, char * > > >> } > > >> > > >> do { > > >> - if ((rc = buf_read_file(f, &buf, &buf_size)) != 0) > > >> + if ((rc = buf_read_file(f, &buf, &buf_size))) > > >> return rc; > > >> > > >> dp = (struct direct *)buf; > > > > > >