diff options
| author | Richard Lowe <richlowe@richlowe.net> | 2012-07-08 19:01:30 +0100 |
|---|---|---|
| committer | Richard Lowe <richlowe@richlowe.net> | 2016-03-05 10:42:06 -0500 |
| commit | 5c5f137104b2d56181283389fa902220f2023809 (patch) | |
| tree | 5819cc5071d40b48d9f06a28b95309a6f8a1ed5d | |
| parent | 876de206688d9fe008ad80c116a23a56701579d1 (diff) | |
| download | illumos-joyent-5c5f137104b2d56181283389fa902220f2023809.tar.gz | |
2976 remove useless offsetof() macros
Reviewed by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
Reviewed by: Andy Stormont <andyjstormont@gmail.com>
Approved by: Dan McDonald <danmcd@omniti.com>
21 files changed, 22 insertions, 74 deletions
diff --git a/usr/src/cmd/fm/fmadm/common/faulty.c b/usr/src/cmd/fm/fmadm/common/faulty.c index 8735b82268..72a8dffb4b 100644 --- a/usr/src/cmd/fm/fmadm/common/faulty.c +++ b/usr/src/cmd/fm/fmadm/common/faulty.c @@ -45,8 +45,7 @@ #include <sys/smbios.h> #include <libdevinfo.h> #include <stdlib.h> - -#define offsetof(s, m) ((size_t)(&(((s*)0)->m))) +#include <stddef.h> /* * Fault records are added to catalog by calling add_fault_record_to_catalog() diff --git a/usr/src/cmd/mdb/common/modules/ii/ii.c b/usr/src/cmd/mdb/common/modules/ii/ii.c index 6169ca0f73..48bc03502b 100644 --- a/usr/src/cmd/mdb/common/modules/ii/ii.c +++ b/usr/src/cmd/mdb/common/modules/ii/ii.c @@ -23,6 +23,8 @@ * Use is subject to license terms. */ +#include <stddef.h> + #include <sys/types.h> #include <sys/mdb_modapi.h> @@ -36,8 +38,6 @@ #include <sys/nsctl/nsvers.h> -#define offsetof(s, m) ((size_t)(&((s *)0)->m)) - const mdb_bitmask_t bi_flags_bits[] = { { "DSW_GOLDEN", DSW_GOLDEN, DSW_GOLDEN }, diff --git a/usr/src/cmd/mdb/common/modules/libumem/misc.h b/usr/src/cmd/mdb/common/modules/libumem/misc.h index 73981fffeb..f12034a299 100644 --- a/usr/src/cmd/mdb/common/modules/libumem/misc.h +++ b/usr/src/cmd/mdb/common/modules/libumem/misc.h @@ -26,16 +26,13 @@ #ifndef _MDBMOD_MISC_H #define _MDBMOD_MISC_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <mdb/mdb_modapi.h> +#include <stddef.h> #ifdef __cplusplus extern "C" { #endif -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) - extern int umem_debug(uintptr_t, uint_t, int, const mdb_arg_t *); extern int umem_set_standalone(void); diff --git a/usr/src/cmd/pools/poolstat/poolstat.c b/usr/src/cmd/pools/poolstat/poolstat.c index ce6ba51d4a..b52b68427f 100644 --- a/usr/src/cmd/pools/poolstat/poolstat.c +++ b/usr/src/cmd/pools/poolstat/poolstat.c @@ -35,6 +35,7 @@ #include <ctype.h> #include <limits.h> #include <errno.h> +#include <stddef.h> #include <pool.h> #include "utils.h" @@ -46,8 +47,6 @@ #define TEXT_DOMAIN "SYS_TEST" #endif -/* calculate offset of a particular element in a structure */ -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) #define addrof(s) ((char **)&(s)) /* verify if a field is printable in respect of the current option flags */ diff --git a/usr/src/cmd/stat/common/acquire_iodevs.c b/usr/src/cmd/stat/common/acquire_iodevs.c index c068ea4b87..762243e3b3 100644 --- a/usr/src/cmd/stat/common/acquire_iodevs.c +++ b/usr/src/cmd/stat/common/acquire_iodevs.c @@ -29,6 +29,7 @@ #include <sys/dktp/fdisk.h> #include <stdlib.h> #include <stdarg.h> +#include <stddef.h> #include <unistd.h> #include <strings.h> #include <errno.h> @@ -147,9 +148,6 @@ find_parent(struct snapshot *ss, struct iodev_snapshot *iodev) * right position in the list. This index is an AVL tree of all the * iodev_snapshot in the list. */ - -#define offsetof(s, m) (size_t)(&(((s *)0)->m)) /* for avl_create */ - static int avl_iodev_cmp(const void* is1, const void* is2) { diff --git a/usr/src/common/nvpair/nvpair.c b/usr/src/common/nvpair/nvpair.c index 691de5d61b..1e20090fba 100644 --- a/usr/src/common/nvpair/nvpair.c +++ b/usr/src/common/nvpair/nvpair.c @@ -36,16 +36,15 @@ #include <sys/varargs.h> #include <sys/ddi.h> #include <sys/sunddi.h> +#include <sys/sysmacros.h> #else #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <strings.h> +#include <stddef.h> #endif -#ifndef offsetof -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) -#endif #define skip_whitespace(p) while ((*(p) == ' ') || (*(p) == '\t')) p++ /* diff --git a/usr/src/lib/libumem/common/misc.h b/usr/src/lib/libumem/common/misc.h index f1fdcc1812..4c47a1c405 100644 --- a/usr/src/lib/libumem/common/misc.h +++ b/usr/src/lib/libumem/common/misc.h @@ -27,13 +27,12 @@ #ifndef _MISC_H #define _MISC_H -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/types.h> #include <sys/time.h> #include <thread.h> #include <pthread.h> #include <stdarg.h> +#include <stddef.h> #ifdef __cplusplus extern "C" { @@ -45,14 +44,6 @@ extern caddr_t umem_min_stack; /* max stack address for audit log */ extern caddr_t umem_max_stack; /* min stack address for audit log */ /* - * various utility functions - * These are globally implemented. - */ - -#undef offsetof -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) - -/* * a safe printf -- do not use for error messages. */ void debug_printf(const char *format, ...); diff --git a/usr/src/lib/lvm/libmeta/common/meta_statconcise.c b/usr/src/lib/lvm/libmeta/common/meta_statconcise.c index 7e61135ecb..7277b5a379 100644 --- a/usr/src/lib/lvm/libmeta/common/meta_statconcise.c +++ b/usr/src/lib/lvm/libmeta/common/meta_statconcise.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <meta.h> #include <assert.h> #include <ctype.h> @@ -32,6 +30,7 @@ #include <meta.h> #include <stdio.h> #include <stdlib.h> +#include <stddef.h> #include <strings.h> #include <sys/lvm/md_mddb.h> #include <sys/lvm/md_names.h> @@ -161,7 +160,6 @@ typedef struct md_im_list { */ #define MAXSIZEMDRECNAME 20 #define NAMEWIDTH 16 -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) #define NOT_PHYSICAL_DEV 0 #define PHYSICAL_DEV 1 diff --git a/usr/src/uts/common/avs/ns/rdc/rdc.c b/usr/src/uts/common/avs/ns/rdc/rdc.c index ffb3dbf208..28750c6e25 100644 --- a/usr/src/uts/common/avs/ns/rdc/rdc.c +++ b/usr/src/uts/common/avs/ns/rdc/rdc.c @@ -33,6 +33,7 @@ #include <sys/modctl.h> #include <sys/cred.h> #include <sys/ddi.h> +#include <sys/sysmacros.h> #include <sys/unistat/spcs_s.h> #include <sys/unistat/spcs_s_k.h> #include <sys/unistat/spcs_errors.h> @@ -521,14 +522,6 @@ convert_ioctl_args(int cmd, intptr_t arg, int mode, _rdc_ioctl_t *args) return (0); } - -/* - * Yet another standard thing that is not standard ... - */ -#ifndef offsetof -#define offsetof(s, m) ((size_t)(&((s *)0)->m)) -#endif - /* * Build a 32bit rdc_set structure and copyout to the user level. */ diff --git a/usr/src/uts/common/avs/ns/rdc/rdc_io.c b/usr/src/uts/common/avs/ns/rdc/rdc_io.c index 16170ad31b..89949b0b33 100644 --- a/usr/src/uts/common/avs/ns/rdc/rdc_io.c +++ b/usr/src/uts/common/avs/ns/rdc/rdc_io.c @@ -29,6 +29,7 @@ #include <sys/kmem.h> #include <sys/conf.h> #include <sys/errno.h> +#include <sys/sysmacros.h> #ifdef _SunOS_5_6 /* @@ -5639,13 +5640,6 @@ done: return (rc); } -/* - * Yet another standard thing that is not standard ... - */ -#ifndef offsetof -#define offsetof(s, m) ((size_t)(&((s *)0)->m)) -#endif - static int rdc_status(void *arg, int mode, rdc_config_t *uparms, spcs_s_info_t kstatus) { diff --git a/usr/src/uts/common/avs/ns/sv/sv.c b/usr/src/uts/common/avs/ns/sv/sv.c index 0edb652242..8ea464cb48 100644 --- a/usr/src/uts/common/avs/ns/sv/sv.c +++ b/usr/src/uts/common/avs/ns/sv/sv.c @@ -74,6 +74,7 @@ #include <sys/cmn_err.h> #include <sys/modctl.h> #include <sys/ddi.h> +#include <sys/sysmacros.h> #include <sys/sunddi.h> #include <sys/sunldi.h> #include <sys/nsctl/nsvers.h> @@ -2415,11 +2416,6 @@ sv_lyr_strategy(struct buf *bp) return (0); } - -#ifndef offsetof -#define offsetof(s, m) ((size_t)(&((s *)0)->m)) -#endif - /* * re-write the size of the current partition */ diff --git a/usr/src/uts/common/inet/ipf/netinet/ip_fil.h b/usr/src/uts/common/inet/ipf/netinet/ip_fil.h index 479a8044f4..2cd33bb91e 100644 --- a/usr/src/uts/common/inet/ipf/netinet/ip_fil.h +++ b/usr/src/uts/common/inet/ipf/netinet/ip_fil.h @@ -672,9 +672,6 @@ typedef struct frentry { #define FR_NOLOGTAG 0 -#ifndef offsetof -#define offsetof(t,m) (size_t)((&((t *)0)->m)) -#endif #define FR_CMPSIZ (sizeof(struct frentry) - \ offsetof(struct frentry, fr_func)) diff --git a/usr/src/uts/common/io/drm/drmP.h b/usr/src/uts/common/io/drm/drmP.h index 77bc2f7a8e..16c02e5d54 100644 --- a/usr/src/uts/common/io/drm/drmP.h +++ b/usr/src/uts/common/io/drm/drmP.h @@ -56,6 +56,7 @@ #include <sys/pmem.h> #include <sys/agpgart.h> #include <sys/time.h> +#include <sys/sysmacros.h> #include "drm_atomic.h" #include "drm.h" #include "queue.h" diff --git a/usr/src/uts/common/io/sfe/sfe_util.c b/usr/src/uts/common/io/sfe/sfe_util.c index fb6d4ceb9b..9c97247f09 100644 --- a/usr/src/uts/common/io/sfe/sfe_util.c +++ b/usr/src/uts/common/io/sfe/sfe_util.c @@ -52,6 +52,7 @@ #include <sys/stream.h> /* required for MBLK* */ #include <sys/strsun.h> /* required for mionack() */ #include <sys/byteorder.h> +#include <sys/sysmacros.h> #include <sys/pci.h> #include <inet/common.h> #include <inet/led.h> @@ -107,9 +108,6 @@ static int gem_debug = GEM_DEBUG_LEVEL; #define GET_TXBUF(dp, sn) \ &(dp)->tx_buf[SLOT((dp)->tx_slots_base + (sn), (dp)->gc.gc_tx_buf_size)] -#ifndef offsetof -#define offsetof(t, m) ((long)&(((t *) 0)->m)) -#endif #define TXFLAG_VTAG(flag) \ (((flag) & GEM_TXFLAG_VTAG) >> GEM_TXFLAG_VTAG_SHIFT) diff --git a/usr/src/uts/common/io/vscan/vscan_svc.c b/usr/src/uts/common/io/vscan/vscan_svc.c index e26fa9e292..a9817f571f 100644 --- a/usr/src/uts/common/io/vscan/vscan_svc.c +++ b/usr/src/uts/common/io/vscan/vscan_svc.c @@ -41,6 +41,7 @@ #include <sys/cred.h> #include <sys/list.h> #include <sys/vscan.h> +#include <sys/sysmacros.h> #define VS_REQ_MAGIC 0x52515354 /* 'RQST' */ @@ -57,7 +58,6 @@ #define VS_ACCESS_DENY 2 /* return EACCES */ #define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C)) -#define offsetof(s, m) (size_t)(&(((s *)0)->m)) /* global variables - tunable via /etc/system */ uint32_t vs_reqs_max = VS_REQS_DEFAULT; /* max scan requests */ diff --git a/usr/src/uts/common/sys/ecppvar.h b/usr/src/uts/common/sys/ecppvar.h index 29b806e3b5..c5159d4bdb 100644 --- a/usr/src/uts/common/sys/ecppvar.h +++ b/usr/src/uts/common/sys/ecppvar.h @@ -28,6 +28,7 @@ #define _SYS_ECPPVAR_H #include <sys/note.h> +#include <sys/sysmacros.h> #ifdef __cplusplus extern "C" { @@ -513,7 +514,6 @@ struct ecppkstat { * Other useful macros */ #define NELEM(a) (sizeof (a) / sizeof (*(a))) -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) #ifdef __cplusplus } diff --git a/usr/src/uts/common/sys/ib/clients/of/sol_ofs/sol_cma.h b/usr/src/uts/common/sys/ib/clients/of/sol_ofs/sol_cma.h index 4b59acbefd..643b720cf2 100644 --- a/usr/src/uts/common/sys/ib/clients/of/sol_ofs/sol_cma.h +++ b/usr/src/uts/common/sys/ib/clients/of/sol_ofs/sol_cma.h @@ -30,14 +30,12 @@ extern "C" { #endif +#include <sys/sysmacros.h> #include <sys/ib/clients/of/sol_ofs/sol_ofs_common.h> #include <sys/ib/clients/of/rdma/rdma_cm.h> #include <sys/ib/clients/of/sol_ofs/sol_ib_cma.h> /* Transport Specific */ -#if !defined(offsetof) -#define offsetof(s, m) (size_t)(&(((s *)0)->m)) -#endif #define IS_UDP_CMID(idp) ((idp)->ps == RDMA_PS_UDP || \ (idp)->ps == RDMA_PS_IPOIB) diff --git a/usr/src/uts/common/sys/usb/clients/audio/usb_ac/usb_ac.h b/usr/src/uts/common/sys/usb/clients/audio/usb_ac/usb_ac.h index ce5c9da5bc..5ef5296a51 100644 --- a/usr/src/uts/common/sys/usb/clients/audio/usb_ac/usb_ac.h +++ b/usr/src/uts/common/sys/usb/clients/audio/usb_ac/usb_ac.h @@ -33,6 +33,7 @@ extern "C" { #endif #include <sys/sunldi.h> +#include <sys/sysmacros.h> #include <sys/usb/usba/usbai_private.h> @@ -329,14 +330,6 @@ _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_audio_format_t::ch)) #define USB_AH_PLUMBED 2 #define UNKNOWN_PLUMBED 3 -/* other useful macros */ -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) - - - - - - #define AF_REGISTERED 0x1 #define AD_SETUP 0x10 diff --git a/usr/src/uts/common/sys/usb/clients/video/usbvc/usbvc_var.h b/usr/src/uts/common/sys/usb/clients/video/usbvc/usbvc_var.h index 04e9eb2dc7..31a6a9fd93 100644 --- a/usr/src/uts/common/sys/usb/clients/video/usbvc/usbvc_var.h +++ b/usr/src/uts/common/sys/usb/clients/video/usbvc/usbvc_var.h @@ -32,6 +32,7 @@ extern "C" { #endif #include <sys/list.h> +#include <sys/sysmacros.h> #include <sys/usb/usba/usbai_private.h> #include <sys/videodev2.h> #include <sys/usb/clients/video/usbvc/usbvc.h> @@ -173,8 +174,6 @@ typedef struct usbvc_vic { #define PRINT_MASK_DEVMAP 0x00000200 #define PRINT_MASK_ALL 0xFFFFFFFF -#define offsetof(s, m) ((size_t)(&(((s *)0)->m))) - #define USBVC_MAX_PKTS 40 #define USBVC_DEFAULT_READ_BUF_NUM 3 diff --git a/usr/src/uts/sun/io/scsi/adapters/sf.c b/usr/src/uts/sun/io/scsi/adapters/sf.c index 8bd12cd74e..885f7d7250 100644 --- a/usr/src/uts/sun/io/scsi/adapters/sf.c +++ b/usr/src/uts/sun/io/scsi/adapters/sf.c @@ -56,9 +56,6 @@ static int sfdebug = 0; static int sf_bus_config_debug = 0; -/* Why do I have to do this? */ -#define offsetof(s, m) (size_t)(&(((s *)0)->m)) - #include <sys/scsi/scsi.h> #include <sys/fc4/fcal.h> #include <sys/fc4/fcp.h> @@ -77,6 +74,7 @@ static int sf_bus_config_debug = 0; #include <sys/devctl.h> #include <sys/scsi/targets/ses.h> #include <sys/callb.h> +#include <sys/sysmacros.h> static int sf_info(dev_info_t *, ddi_info_cmd_t, void *, void **); static int sf_attach(dev_info_t *, ddi_attach_cmd_t); diff --git a/usr/src/uts/sun4u/io/rmclomv.c b/usr/src/uts/sun4u/io/rmclomv.c index 93e236b121..13c10e3a01 100644 --- a/usr/src/uts/sun4u/io/rmclomv.c +++ b/usr/src/uts/sun4u/io/rmclomv.c @@ -52,8 +52,8 @@ #include <sys/ddi.h> #include <sys/time.h> #include <sys/promif.h> +#include <sys/sysmacros.h> -#define offsetof(s, m) (size_t)(&(((s *)0)->m)) #define RMCRESBUFLEN 1024 #define DATE_TIME_MSG_SIZE 78 #define RMCLOMV_WATCHDOG_MODE "rmclomv-watchdog-mode" |
