Print this page
3373 gcc >= 4.5 concerns about offsetof()


 131                         return (pos);
 132                 if (pos->is_type != IODEV_CONTROLLER)
 133                         continue;
 134                 for (pos2 = pos->is_children; pos2; pos2 = pos2->is_next) {
 135                         if (pos2->is_type != IODEV_DISK)
 136                                 continue;
 137                         if (id_match(&iodev->is_parent_id, &pos2->is_id))
 138                                 return (pos2);
 139                 }
 140         }
 141 
 142         return (NULL);
 143 }
 144 
 145 /*
 146  * Introduce an index into the list to speed up insert_into looking for the
 147  * right position in the list. This index is an AVL tree of all the
 148  * iodev_snapshot in the list.
 149  */
 150 
 151 #define offsetof(s, m)  (size_t)(&(((s *)0)->m)) /* for avl_create */




 152 
 153 static int
 154 avl_iodev_cmp(const void* is1, const void* is2)
 155 {
 156         int c = iodev_cmp((struct iodev_snapshot *)is1,
 157             (struct iodev_snapshot *)is2);
 158 
 159         if (c > 0)
 160                 return (1);
 161 
 162         if (c < 0)
 163                 return (-1);
 164 
 165         return (0);
 166 }
 167 
 168 static void
 169 ix_new_list(struct iodev_snapshot *elem)
 170 {
 171         avl_tree_t *l = malloc(sizeof (avl_tree_t));




 131                         return (pos);
 132                 if (pos->is_type != IODEV_CONTROLLER)
 133                         continue;
 134                 for (pos2 = pos->is_children; pos2; pos2 = pos2->is_next) {
 135                         if (pos2->is_type != IODEV_DISK)
 136                                 continue;
 137                         if (id_match(&iodev->is_parent_id, &pos2->is_id))
 138                                 return (pos2);
 139                 }
 140         }
 141 
 142         return (NULL);
 143 }
 144 
 145 /*
 146  * Introduce an index into the list to speed up insert_into looking for the
 147  * right position in the list. This index is an AVL tree of all the
 148  * iodev_snapshot in the list.
 149  */
 150 
 151 #if defined(__GNUC__)
 152 #define offsetof(s, m)  __builtin_offsetof(s, m)
 153 #else
 154 #define offsetof(s, m)  ((size_t)(&(((s *)0)->m)))       /* for avl_create */
 155 #endif
 156 
 157 static int
 158 avl_iodev_cmp(const void* is1, const void* is2)
 159 {
 160         int c = iodev_cmp((struct iodev_snapshot *)is1,
 161             (struct iodev_snapshot *)is2);
 162 
 163         if (c > 0)
 164                 return (1);
 165 
 166         if (c < 0)
 167                 return (-1);
 168 
 169         return (0);
 170 }
 171 
 172 static void
 173 ix_new_list(struct iodev_snapshot *elem)
 174 {
 175         avl_tree_t *l = malloc(sizeof (avl_tree_t));