Skip to content
Browse files

2061 uts homebrew offsetofs cause various pointer-cast warnings

Reviewed by: Joshua M. Clulow <josh@sysmgr.org>
Reviewed by: Jason King <jason.brian.king@gmail.com>
Reviewed by: Darren Reed <avalon@coombs.anu.edu.au>
Approved by: Garrett D'Amore <garrett@damore.org>
  • Loading branch information...
1 parent aac5176 commit ad9a7bd3532cf0ef931ded51a5ffe5d0496aad88 @richlowe richlowe committed
View
23 usr/src/uts/common/avs/ns/dsw/dsw_dev.c
@@ -32,6 +32,7 @@
#include <sys/debug.h>
#include <sys/ddi.h>
#include <sys/nsc_thread.h>
+#include <sys/sysmacros.h>
#include <sys/unistat/spcs_s.h>
#include <sys/unistat/spcs_errors.h>
@@ -67,7 +68,7 @@
#define II_TAIL_COPY(d, s, m, t) bcopy(&(s.m), &(d.m), \
- sizeof (d) - (uint_t)&((t *)0)->m)
+ sizeof (d) - (uintptr_t)&((t *)0)->m)
extern dev_info_t *ii_dip;
#define II_LINK_CLUSTER(ip, cluster) \
@@ -4234,7 +4235,8 @@ _ii_gc_list(intptr_t arg, int ilp32, int *rvp, kmutex_t *mutex,
{
dsw_aioctl_t ulist;
dsw_aioctl32_t ulist32;
- int name_offset, i;
+ size_t name_offset;
+ int i;
spcs_s_info_t kstatus;
char *carg = (char *)arg;
uint64_t hash;
@@ -4242,13 +4244,13 @@ _ii_gc_list(intptr_t arg, int ilp32, int *rvp, kmutex_t *mutex,
_ii_lstinfo_t *np;
*rvp = 0;
- name_offset = (int)&(((dsw_aioctl_t *)0)->shadow_vol[0]);
+ name_offset = offsetof(dsw_aioctl_t, shadow_vol[0]);
if (ilp32) {
if (copyin((void *) arg, &ulist32, sizeof (ulist32)) < 0)
return (EFAULT);
II_TAIL_COPY(ulist, ulist32, flags, dsw_aioctl_t);
ulist.status = (spcs_s_info_t)ulist32.status;
- name_offset = (int)&(((dsw_aioctl32_t *)0)->shadow_vol[0]);
+ name_offset = offsetof(dsw_aioctl32_t, shadow_vol[0]);
} else if (copyin((void *) arg, &ulist, sizeof (ulist)) < 0)
return (EFAULT);
@@ -4323,20 +4325,21 @@ _ii_olist(intptr_t arg, int ilp32, int *rvp)
dsw_aioctl_t ulist;
dsw_aioctl32_t ulist32;
_ii_overflow_t *op;
+ size_t name_offset;
int rc = 0;
- int name_offset, i;
+ int i;
char *carg = (char *)arg;
spcs_s_info_t kstatus;
*rvp = 0;
- name_offset = (int)&(((dsw_aioctl_t *)0)->shadow_vol[0]);
+ name_offset = offsetof(dsw_aioctl_t, shadow_vol[0]);
if (ilp32) {
if (copyin((void *)arg, &ulist32, sizeof (ulist32)) < 0)
return (EFAULT);
II_TAIL_COPY(ulist, ulist32, flags, dsw_aioctl_t);
ulist.status = (spcs_s_info_t)ulist32.status;
- name_offset = (int)&(((dsw_aioctl32_t *)0)->shadow_vol[0]);
+ name_offset = offsetof(dsw_aioctl32_t, shadow_vol[0]);
} else if (copyin((void *)arg, &ulist, sizeof (ulist)) < 0)
return (EFAULT);
@@ -5220,7 +5223,7 @@ int
_ii_acopy(intptr_t arg, int ilp32, int *rvp)
{
int rc;
- int name_offset;
+ size_t name_offset;
char *list;
char *nptr;
char name[DSW_NAMELEN];
@@ -5230,14 +5233,14 @@ _ii_acopy(intptr_t arg, int ilp32, int *rvp)
*rvp = 0;
- name_offset = (int)&(((dsw_aioctl_t *)0)->shadow_vol[0]);
+ name_offset = offsetof(dsw_aioctl_t, shadow_vol[0]);
if (ilp32) {
if (copyin((void *)arg, &ucopy32, sizeof (ucopy32)) < 0)
return (EFAULT);
II_TAIL_COPY(ucopy, ucopy32, flags, dsw_ioctl_t);
ucopy.status = (spcs_s_info_t)ucopy32.status;
- name_offset = (int)&(((dsw_aioctl32_t *)0)->shadow_vol[0]);
+ name_offset = offsetof(dsw_aioctl32_t, shadow_vol[0]);
} else if (copyin((void *)arg, &ucopy, sizeof (ucopy)) < 0)
return (EFAULT);
View
128 usr/src/uts/common/fs/udfs/udf_alloc.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/t_lock.h>
#include <sys/param.h>
@@ -175,10 +173,10 @@ ud_alloc_space(struct vfs *vfsp, uint16_t prn,
if (ud_part->udp_nfree != 0) {
if (ud_part->udp_flags == UDP_BITMAPS) {
error = ud_alloc_space_bmap(vfsp, ud_part, proximity,
- blkcount, start_blkno, size, less_is_ok);
+ blkcount, start_blkno, size, less_is_ok);
} else {
error = ud_alloc_space_stbl(vfsp, ud_part, proximity,
- blkcount, start_blkno, size, less_is_ok);
+ blkcount, start_blkno, size, less_is_ok);
}
if (error == 0) {
mutex_enter(&udf_vfsp->udf_lock);
@@ -258,7 +256,7 @@ ud_alloc_space_bmap(struct vfs *vfsp,
*/
temp = blkcount;
if (ud_check_free_and_mark_used(vfsp,
- ud_part, proximity, &temp) == 0) {
+ ud_part, proximity, &temp) == 0) {
if (temp != 0) {
*start_blkno = proximity;
*size = temp;
@@ -290,17 +288,17 @@ ud_alloc_space_bmap(struct vfs *vfsp,
* due to the way bread is implemented
*/
if ((bp == NULL) ||
- ((eblk - bno) < blkcount)) {
+ ((eblk - bno) < blkcount)) {
if (bp != NULL) {
brelse(bp);
}
begin = ud_part->udp_unall_loc +
- bno / bb_count;
+ bno / bb_count;
bp = ud_bread(vfsp->vfs_dev,
- ud_xlate_to_daddr(udf_vfsp,
- ud_part->udp_number,
- begin, 1, &dummy)
- << udf_vfsp->udf_l2d_shift, lbsz);
+ ud_xlate_to_daddr(udf_vfsp,
+ ud_part->udp_number,
+ begin, 1, &dummy) <<
+ udf_vfsp->udf_l2d_shift, lbsz);
if (bp->b_flags & B_ERROR) {
brelse(bp);
return (EIO);
@@ -317,14 +315,14 @@ ud_alloc_space_bmap(struct vfs *vfsp,
temp = blkcount;
}
if ((new_size = ud_check_free(addr, eaddr,
- bno - bblk, temp)) == temp) {
+ bno - bblk, temp)) == temp) {
ud_mark_used(addr, bno - bblk, temp);
bdwrite(bp);
*start_blkno = bno - HDR_BLKS;
*size = temp;
mutex_enter(&udf_vfsp->udf_lock);
ud_part->udp_last_alloc =
- bno + temp - HDR_BLKS;
+ bno + temp - HDR_BLKS;
mutex_exit(&udf_vfsp->udf_lock);
return (0);
}
@@ -380,7 +378,7 @@ ud_alloc_space_bmap(struct vfs *vfsp,
* already allocated behind us
*/
if (ud_check_free_and_mark_used(vfsp,
- ud_part, old_loc, &old_size) == 0) {
+ ud_part, old_loc, &old_size) == 0) {
if (old_size != 0) {
*start_blkno = old_loc;
*size = old_size;
@@ -423,9 +421,9 @@ ud_check_free_and_mark_used(struct vfs *vfsp,
*/
begin = ud_part->udp_unall_loc + (start / bb_count);
bp = ud_bread(vfsp->vfs_dev,
- ud_xlate_to_daddr(udf_vfsp, ud_part->udp_number,
- begin, 1, &dummy) << udf_vfsp->udf_l2d_shift,
- udf_vfsp->udf_lbsize);
+ ud_xlate_to_daddr(udf_vfsp, ud_part->udp_number,
+ begin, 1, &dummy) << udf_vfsp->udf_l2d_shift,
+ udf_vfsp->udf_lbsize);
if (bp->b_flags & B_ERROR) {
brelse(bp);
return (EIO);
@@ -440,8 +438,8 @@ ud_check_free_and_mark_used(struct vfs *vfsp,
ASSERT(*count > 0);
}
if (ud_check_free((uint8_t *)bp->b_un.b_addr,
- (uint8_t *)bp->b_un.b_addr + bp->b_bcount,
- start, *count) != *count) {
+ (uint8_t *)bp->b_un.b_addr + bp->b_bcount, start,
+ *count) != *count) {
brelse(bp);
return (1);
}
@@ -517,9 +515,8 @@ ud_alloc_space_stbl(struct vfs *vfsp,
ASSERT((ud_part->udp_unall_len + 40) <= udf_vfsp->udf_lbsize);
bp = ud_bread(vfsp->vfs_dev,
- ud_xlate_to_daddr(udf_vfsp, ud_part->udp_number,
- ud_part->udp_unall_loc, 1, &temp),
- udf_vfsp->udf_lbsize);
+ ud_xlate_to_daddr(udf_vfsp, ud_part->udp_number,
+ ud_part->udp_unall_loc, 1, &temp), udf_vfsp->udf_lbsize);
use = (struct unall_space_ent *)bp->b_un.b_addr;
sz = SWAP_32(use->use_len_ad);
@@ -538,7 +535,7 @@ ud_alloc_space_stbl(struct vfs *vfsp,
larg_index = larg_sz = 0;
for (index = 0; index < count; index++, sad++) {
temp = SWAP_32(sad->sad_ext_len) >>
- udf_vfsp->udf_l2b_shift;
+ udf_vfsp->udf_l2b_shift;
if (temp == blkcount) {
/*
* We found the right fit
@@ -559,7 +556,7 @@ ud_alloc_space_stbl(struct vfs *vfsp,
*start_blkno = SWAP_32(sad->sad_ext_loc);
*size = blkcount;
temp = (temp - blkcount) <<
- udf_vfsp->udf_l2b_shift;
+ udf_vfsp->udf_l2b_shift;
sad->sad_ext_len = SWAP_32(temp);
temp = SWAP_32(sad->sad_ext_loc) + blkcount;
sad->sad_ext_loc = SWAP_32(temp);
@@ -577,8 +574,7 @@ ud_alloc_space_stbl(struct vfs *vfsp,
}
}
compress_sad:
- if ((less_is_ok) &&
- (larg_sz != 0)) {
+ if ((less_is_ok) && (larg_sz != 0)) {
/*
* If we came here we could
* not find a extent to cover the entire size
@@ -590,7 +586,7 @@ ud_alloc_space_stbl(struct vfs *vfsp,
*start_blkno = SWAP_32(sad->sad_ext_loc);
*size = larg_sz;
for (index = larg_index; index < count;
- index++, sad++) {
+ index++, sad++) {
*sad = *(sad+1);
}
sz -= sizeof (struct short_ad);
@@ -613,7 +609,7 @@ ud_alloc_space_stbl(struct vfs *vfsp,
larg_index = larg_sz = 0;
for (index = 0; index < count; index++, lad++) {
temp = SWAP_32(lad->lad_ext_len) >>
- udf_vfsp->udf_l2b_shift;
+ udf_vfsp->udf_l2b_shift;
if (temp == blkcount) {
/*
* We found the right fit
@@ -634,7 +630,7 @@ ud_alloc_space_stbl(struct vfs *vfsp,
*start_blkno = SWAP_32(lad->lad_ext_loc);
*size = blkcount;
temp = (temp - blkcount) <<
- udf_vfsp->udf_l2b_shift;
+ udf_vfsp->udf_l2b_shift;
lad->lad_ext_len = SWAP_32(temp);
temp = SWAP_32(lad->lad_ext_loc) + blkcount;
lad->lad_ext_loc = SWAP_32(temp);
@@ -652,8 +648,7 @@ ud_alloc_space_stbl(struct vfs *vfsp,
}
}
compress_lad:
- if ((less_is_ok) &&
- (larg_sz != 0)) {
+ if ((less_is_ok) && (larg_sz != 0)) {
/*
* If we came here we could
* not find a extent to cover the entire size
@@ -665,7 +660,7 @@ ud_alloc_space_stbl(struct vfs *vfsp,
*start_blkno = SWAP_32(lad->lad_ext_loc);
*size = larg_sz;
for (index = larg_index; index < count;
- index++, lad++) {
+ index++, lad++) {
*lad = *(lad+1);
}
sz -= sizeof (struct long_ad);
@@ -755,7 +750,7 @@ ud_free_space_bmap(struct vfs *vfsp,
udf_vfsp = (struct udf_vfs *)vfsp->vfs_data;
if ((ud_part->udp_freed_len == 0) &&
- (ud_part->udp_unall_len == 0)) {
+ (ud_part->udp_unall_len == 0)) {
return (ENOSPC);
}
/*
@@ -782,10 +777,8 @@ ud_free_space_bmap(struct vfs *vfsp,
for (block = begin; block <= end; block++) {
bp = ud_bread(vfsp->vfs_dev,
- ud_xlate_to_daddr(udf_vfsp,
- ud_part->udp_number, block, 1, &dummy)
- << udf_vfsp->udf_l2d_shift,
- udf_vfsp->udf_lbsize);
+ ud_xlate_to_daddr(udf_vfsp, ud_part->udp_number, block, 1,
+ &dummy) << udf_vfsp->udf_l2d_shift, udf_vfsp->udf_lbsize);
if (bp->b_flags & B_ERROR) {
brelse(bp);
return (EIO);
@@ -855,8 +848,7 @@ ud_free_space_stbl(struct vfs *vfsp,
ASSERT(ud_part);
ASSERT(ud_part->udp_flags == UDP_SPACETBLS);
- if ((ud_part->udp_freed_len == 0) &&
- (ud_part->udp_unall_len == 0)) {
+ if ((ud_part->udp_freed_len == 0) && (ud_part->udp_unall_len == 0)) {
return (ENOSPC);
}
@@ -870,8 +862,8 @@ ud_free_space_stbl(struct vfs *vfsp,
ASSERT((ud_part->udp_unall_len + 40) <= udf_vfsp->udf_lbsize);
bp = ud_bread(vfsp->vfs_dev,
- ud_xlate_to_daddr(udf_vfsp, ud_part->udp_number,
- block, 1, &dummy), udf_vfsp->udf_lbsize);
+ ud_xlate_to_daddr(udf_vfsp, ud_part->udp_number, block, 1, &dummy),
+ udf_vfsp->udf_lbsize);
use = (struct unall_space_ent *)bp->b_un.b_addr;
sz = SWAP_32(use->use_len_ad);
@@ -888,14 +880,14 @@ ud_free_space_stbl(struct vfs *vfsp,
*/
for (index = 0; index < count; index++, sad++) {
if (beginblk == (SWAP_32(sad->sad_ext_loc) +
- (SWAP_32(sad->sad_ext_len) /
- udf_vfsp->udf_lbsize))) {
+ (SWAP_32(sad->sad_ext_len) /
+ udf_vfsp->udf_lbsize))) {
dummy = SWAP_32(sad->sad_ext_len) +
- blkcount * udf_vfsp->udf_lbsize;
+ blkcount * udf_vfsp->udf_lbsize;
sad->sad_ext_len = SWAP_32(dummy);
goto end;
} else if ((beginblk + blkcount) ==
- SWAP_32(sad->sad_ext_loc)) {
+ SWAP_32(sad->sad_ext_loc)) {
sad->sad_ext_loc = SWAP_32(beginblk);
goto end;
}
@@ -906,7 +898,7 @@ ud_free_space_stbl(struct vfs *vfsp,
* Check if we space.
*/
if ((40 + sz + sizeof (struct short_ad)) >
- udf_vfsp->udf_lbsize) {
+ udf_vfsp->udf_lbsize) {
error = ENOSPC;
goto end;
}
@@ -934,14 +926,14 @@ ud_free_space_stbl(struct vfs *vfsp,
*/
for (index = 0; index < count; index++, lad++) {
if (beginblk == (SWAP_32(lad->lad_ext_loc) +
- (SWAP_32(lad->lad_ext_len) /
- udf_vfsp->udf_lbsize))) {
+ (SWAP_32(lad->lad_ext_len) /
+ udf_vfsp->udf_lbsize))) {
dummy = SWAP_32(lad->lad_ext_len) +
- blkcount * udf_vfsp->udf_lbsize;
+ blkcount * udf_vfsp->udf_lbsize;
lad->lad_ext_len = SWAP_32(dummy);
goto end;
} else if ((beginblk + blkcount) ==
- SWAP_32(lad->lad_ext_loc)) {
+ SWAP_32(lad->lad_ext_loc)) {
lad->lad_ext_loc = SWAP_32(beginblk);
goto end;
}
@@ -952,7 +944,7 @@ ud_free_space_stbl(struct vfs *vfsp,
* Check if we space.
*/
if ((40 + sz + sizeof (struct long_ad)) >
- udf_vfsp->udf_lbsize) {
+ udf_vfsp->udf_lbsize) {
error = ENOSPC;
goto end;
}
@@ -1019,7 +1011,7 @@ ud_ialloc(struct ud_inode *pip,
prn = pip->i_icb_prn;
if ((err = ud_alloc_space(pip->i_vfs, prn,
- 0, 1, &blkno, &size, 0, 1)) != 0) {
+ 0, 1, &blkno, &size, 0, 1)) != 0) {
return (err);
}
loc = ud_xlate_to_daddr(udf_vfsp, prn, blkno, 1, &dummy);
@@ -1048,8 +1040,8 @@ ud_ialloc(struct ud_inode *pip,
* 3) Otherwise, set the group-id to the gid of the parent directory.
*/
if ((vap->va_mask & AT_GID) &&
- ((vap->va_gid == pip->i_gid) || groupmember(vap->va_gid, cr) ||
- secpolicy_vnode_create_gid(cr) == 0)) {
+ ((vap->va_gid == pip->i_gid) || groupmember(vap->va_gid, cr) ||
+ secpolicy_vnode_create_gid(cr) == 0)) {
/*
* XXX - is this only the case when a 4.0 NFS client, or a
* client derived from that code, makes a call over the wire?
@@ -1058,7 +1050,7 @@ ud_ialloc(struct ud_inode *pip,
} else {
gid = crgetgid(cr);
fe->fe_gid = (pip->i_char & ISGID) ?
- SWAP_32(pip->i_gid) : SWAP_32(gid);
+ SWAP_32(pip->i_gid) : SWAP_32(gid);
}
imode = MAKEIMODE(vap->va_type, vap->va_mode);
@@ -1115,19 +1107,18 @@ ud_ialloc(struct ud_inode *pip,
mutex_exit(&udf_vfsp->udf_lock);
ea_len = 0;
- if ((vap->va_type == VBLK) ||
- (vap->va_type == VCHR)) {
+ if ((vap->va_type == VBLK) || (vap->va_type == VCHR)) {
eah = (struct ext_attr_hdr *)fe->fe_spec;
ea_len = (sizeof (struct ext_attr_hdr) + 3) & ~3;
eah->eah_ial = SWAP_32(ea_len);
ds = (struct dev_spec_ear *)&fe->fe_spec[ea_len];
ea_len += ud_make_dev_spec_ear(ds,
- getmajor(vap->va_rdev), getminor(vap->va_rdev));
+ getmajor(vap->va_rdev), getminor(vap->va_rdev));
ea_len = (ea_len + 3) & ~3;
eah->eah_aal = SWAP_32(ea_len);
ud_make_tag(udf_vfsp, &eah->eah_tag,
- UD_EXT_ATTR_HDR, blkno, ea_len);
+ UD_EXT_ATTR_HDR, blkno, ea_len);
}
fe->fe_len_ear = SWAP_32(ea_len);
@@ -1172,7 +1163,7 @@ ud_ialloc(struct ud_inode *pip,
} else {
if ((ichar & ISGID) &&
secpolicy_vnode_setids_setgids(cr,
- (gid_t)SWAP_32(fe->fe_gid)) != 0) {
+ (gid_t)SWAP_32(fe->fe_gid)) != 0) {
ichar &= ~ISGID;
}
}
@@ -1187,8 +1178,8 @@ ud_ialloc(struct ud_inode *pip,
}
icb->itag_flags = SWAP_16(flags);
ud_make_tag(udf_vfsp, &fe->fe_tag, UD_FILE_ENTRY, blkno,
- ((uint32_t)&((struct file_entry *)0)->fe_spec) +
- SWAP_32(fe->fe_len_ear) + SWAP_32(fe->fe_len_adesc));
+ offsetof(struct file_entry, fe_spec) +
+ SWAP_32(fe->fe_len_ear) + SWAP_32(fe->fe_len_adesc));
BWRITE2(bp);
@@ -1206,7 +1197,7 @@ ud_ialloc(struct ud_inode *pip,
if ((ip = ud_search_icache(pip->i_vfs, prn, blkno)) != NULL) {
cmn_err(CE_NOTE, "duplicate %p %x\n",
- (void *)ip, (uint32_t)ip->i_icb_lbano);
+ (void *)ip, (uint32_t)ip->i_icb_lbano);
}
}
#endif
@@ -1239,8 +1230,7 @@ ud_ifree(struct ud_inode *ip, vtype_t type)
udf_vfsp = (struct udf_vfs *)ip->i_vfs->vfs_data;
bp = ud_bread(ip->i_dev, ip->i_icb_lbano <<
- udf_vfsp->udf_l2d_shift,
- udf_vfsp->udf_lbsize);
+ udf_vfsp->udf_l2d_shift, udf_vfsp->udf_lbsize);
if (bp->b_flags & B_ERROR) {
/*
* Error get rid of bp
@@ -1253,8 +1243,7 @@ ud_ifree(struct ud_inode *ip, vtype_t type)
bzero(bp->b_un.b_addr, 0x10);
BWRITE(bp);
}
- ud_free_space(ip->i_vfs, ip->i_icb_prn,
- ip->i_icb_block, 1);
+ ud_free_space(ip->i_vfs, ip->i_icb_prn, ip->i_icb_block, 1);
mutex_enter(&udf_vfsp->udf_lock);
if (type == VDIR) {
if (udf_vfsp->udf_ndirs > 1) {
@@ -1377,8 +1366,7 @@ ud_alloc_from_cache(struct udf_vfs *udf_vfsp,
mutex_exit(&udf_vfsp->udf_lock);
/* allocate new cluster */
if ((error = ud_alloc_space(udf_vfsp->udf_vfs,
- part->udp_number, 0, CLSTR_SIZE,
- &bno, &sz, 1, 0)) != 0) {
+ part->udp_number, 0, CLSTR_SIZE, &bno, &sz, 1, 0)) != 0) {
return (error);
}
if (sz == 0) {
@@ -1424,7 +1412,7 @@ ud_release_cache(struct udf_vfs *udf_vfsp)
part->udp_cache_count = 0;
mutex_exit(&udf_vfsp->udf_lock);
ud_free_space(udf_vfsp->udf_vfs,
- part->udp_number, start, nblks);
+ part->udp_number, start, nblks);
mutex_enter(&udf_vfsp->udf_lock);
}
}
View
5 usr/src/uts/common/fs/udfs/udf_inode.c
@@ -1153,10 +1153,11 @@ void
ud_iupdat(struct ud_inode *ip, int32_t waitfor)
{
uint16_t flag, tag_flags;
- int32_t error, crc_len = 0;
+ int32_t error;
struct buf *bp;
struct udf_vfs *udf_vfsp;
struct file_entry *fe;
+ uint16_t crc_len = 0;
ASSERT(RW_WRITE_HELD(&ip->i_contents));
@@ -1237,7 +1238,7 @@ ud_iupdat(struct ud_inode *ip, int32_t waitfor)
ud_update_regid(&fe->fe_impl_id);
- crc_len = ((uint32_t)&((struct file_entry *)0)->fe_spec) +
+ crc_len = offsetof(struct file_entry, fe_spec) +
SWAP_32(fe->fe_len_ear);
if (ip->i_desc_type == ICB_FLAG_ONE_AD) {
crc_len += ip->i_size;
View
4 usr/src/uts/common/fs/udfs/udf_vnops.c
@@ -2759,7 +2759,7 @@ ud_putapage(struct vnode *vp,
struct buf *bp = NULL;
int32_t lbmask;
uint64_t isize;
- int32_t crc_len;
+ uint16_t crc_len;
struct file_entry *fe;
ud_printf("ud_putapage\n");
@@ -2831,7 +2831,7 @@ ud_putapage(struct vnode *vp,
(void) kcopy(kaddr, caddr, ip->i_size);
ppmapout(kaddr);
}
- crc_len = ((uint32_t)&((struct file_entry *)0)->fe_spec) +
+ crc_len = offsetof(struct file_entry, fe_spec) +
SWAP_32(fe->fe_len_ear);
crc_len += ip->i_size;
ud_make_tag(ip->i_udf, &fe->fe_tag,
View
4 usr/src/uts/common/sys/pathconf.h
@@ -26,8 +26,6 @@
#ifndef _SYS_PATHCONF_H
#define _SYS_PATHCONF_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/* pathconf.h 1.9 89/06/26 SMI */
#include <sys/unistd.h>
@@ -118,7 +116,7 @@ struct pathcnf32 {
* The size of the non-kernel part of the struct.
*/
#ifdef _KERNEL
-#define PCSIZ (int)(&(((struct pathcnf *)0)->pc_refcnt))
+#define PCSIZ ((size_t)(&(((struct pathcnf *)0)->pc_refcnt)))
#define PCCMP(p1, p2) bcmp((char *)p1, (char *)p2, PCSIZ)
#endif
View
7 usr/src/uts/sun4u/starcat/io/mboxsc.c
@@ -156,10 +156,9 @@ typedef struct mboxsc_mbox {
(((tid) == 0) || ((tid) == (msgp)->msg_transid))
/*
- * These macros can be used to determine the offset or size of any field in the
- * message header (or any other struct, for that matter).
+ * This macro can be used to determine the size of any field in the message
+ * header (or any other struct, for that matter).
*/
-#define FIELD_OFFSET(type, field) ((uint32_t)&(((type *)0)->field))
#define FIELD_SIZE(type, field) (sizeof (((type *)0)->field))
/*
@@ -1079,7 +1078,7 @@ mboxsc_getmsg(uint32_t key, uint32_t *typep, uint32_t *cmdp, uint64_t *transidp,
if ((error == 0) && (data_valid == IOSRAM_DATA_VALID)) {
error = mboxsc_timed_read(deadline, key,
- FIELD_OFFSET(mboxsc_msghdr_t, msg_transid),
+ offsetof(mboxsc_msghdr_t, msg_transid),
FIELD_SIZE(mboxsc_msghdr_t, msg_transid),
(caddr_t)&read_transid);
}
View
23 usr/src/uts/sun4u/starcat/sys/domaind.h
@@ -27,12 +27,11 @@
#ifndef _SYS_DOMAIND_H
#define _SYS_DOMAIND_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
+#include <sys/sysmacros.h>
#include <sys/cpu_sgnblk_defs.h>
typedef struct domain_data {
@@ -57,16 +56,16 @@ typedef struct domain_data {
/*
* offsets
*/
-#define DOMD_MAGIC_OFFSET ((uint32_t)&((domain_data_t *)0)->magic)
-#define DOMD_VERSION_OFFSET ((uint32_t)&((domain_data_t *)0)->version)
-#define DOMD_KEYSWITCH_OFFSET ((uint32_t)&((domain_data_t *)0)->keyswitch)
-#define DOMD_SCIP_OFFSET ((uint32_t)&((domain_data_t *)0)->master_sc_ip)
-#define DOMD_LEDS_OFFSET ((uint32_t)&((domain_data_t *)0)->leds)
-#define DOMD_DSTATE_OFFSET ((uint32_t)&((domain_data_t *)0)->domain_state)
-#define DOMD_HEARTBEAT_OFFSET ((uint32_t)&((domain_data_t *)0)->heartbeat)
-#define DOMD_CPUSPRESENT_OFFSET ((uint32_t)&((domain_data_t *)0)->cpus_present)
-#define DOMD_CPUSIGS_OFFSET ((uint32_t)&((domain_data_t *)0)->cpu_sigs)
-#define DOMD_RESETINFO_OFFSET ((uint32_t)&((domain_data_t *)0)->resetinfo_off)
+#define DOMD_MAGIC_OFFSET offsetof(domain_data_t, magic)
+#define DOMD_VERSION_OFFSET offsetof(domain_data_t, version)
+#define DOMD_KEYSWITCH_OFFSET offsetof(domain_data_t, keyswitch)
+#define DOMD_SCIP_OFFSET offsetof(domain_data_t, master_sc_ip)
+#define DOMD_LEDS_OFFSET offsetof(domain_data_t, leds)
+#define DOMD_DSTATE_OFFSET offsetof(domain_data_t, domain_state)
+#define DOMD_HEARTBEAT_OFFSET offsetof(domain_data_t, heartbeat)
+#define DOMD_CPUSPRESENT_OFFSET offsetof(domain_data_t, cpus_present)
+#define DOMD_CPUSIGS_OFFSET offsetof(domain_data_t, cpu_sigs)
+#define DOMD_RESETINFO_OFFSET offsetof(domain_data_t, resetinfo_off)
/*
* tod
View
4 usr/src/uts/sun4u/starcat/sys/sc_cvcio.h
@@ -27,7 +27,7 @@
#ifndef _SYS_SC_CVCIO_H
#define _SYS_SC_CVCIO_H
-#pragma ident "%Z%%M% %I% %E% SMI"
+#include <sys/sysmacros.h>
#ifdef __cplusplus
extern "C" {
@@ -120,7 +120,7 @@ typedef struct cvc_ctl {
* These macros can be used to determine the offset or size of any field in the
* CONC chunk.
*/
-#define CVC_CTL_OFFSET(field) ((uint32_t)&(((cvc_ctl_t *)0)->field))
+#define CVC_CTL_OFFSET(field) offsetof(cvc_ctl_t, field)
#define CVC_CTL_SIZE(field) (sizeof (((cvc_ctl_t *)0)->field))
/*
View
2 usr/src/uts/sun4u/starfire/io/idn.c
@@ -620,7 +620,7 @@ idnattach(dev_info_t *dip, ddi_attach_cmd_t cmd)
#ifndef lint
ASSERT(sizeof (idnsb_t) == IDNSB_SIZE);
- ASSERT((uint_t)&((struct idnsb *)0)->id_hwchkpt[0] == 0x40);
+ ASSERT(offsetof(struct idnsb, id_hwchkpt[0]) == 0x40);
#endif /* lint */
switch (cmd) {

0 comments on commit ad9a7bd

Please sign in to comment.
Something went wrong with that request. Please try again.