1 /* Reduced from linux-5.10.162's drivers-base-bus.c */
2 /* { dg-additional-options "-fno-delete-null-pointer-checks -O2" } */
4 #include "../../gcc.dg/analyzer/analyzer-decls.h"
7 typedef unsigned int __kernel_size_t
;
8 typedef int __kernel_ssize_t
;
9 typedef __kernel_size_t
size_t;
10 typedef __kernel_ssize_t ssize_t
;
14 struct list_head
*next
, *prev
;
29 sysfs_remove_file_ns(struct kobject
* kobj
,
30 const struct attribute
* attr
,
37 sysfs_remove_file(struct kobject
* kobj
, const struct attribute
* attr
)
39 sysfs_remove_file_ns(kobj
, attr
, NULL
);
42 extern struct kobject
*
43 kobject_get(struct kobject
* kobj
);
46 kobject_put(struct kobject
* kobj
);
50 struct list_head list
;
54 } __attribute__((__designated_init__
));
58 to_kset(struct kobject
* kobj
)
61 char* __mptr
= (char*)(kobj
);
62 ((struct kset
*)(__mptr
- __builtin_offsetof(struct kset
, kobj
)));
68 kset_get(struct kset
* k
)
70 return k
? to_kset(kobject_get(&k
->kobj
)) : NULL
;
75 kset_put(struct kset
* k
)
77 kobject_put(&k
->kobj
);
83 struct device
* dev_root
;
85 struct subsys_private
* p
;
91 struct attribute attr
;
96 device_unregister(struct device
* dev
);
104 static struct bus_type
*
105 bus_get(struct bus_type
* bus
)
107 if (bus
) { /* { dg-bogus "check of 'bus' for NULL after already dereferencing it" } */
108 kset_get(&bus
->p
->subsys
);
115 bus_put(struct bus_type
* bus
)
118 kset_put(&bus
->p
->subsys
);
122 bus_remove_file(struct bus_type
* bus
, struct bus_attribute
* attr
)
125 sysfs_remove_file(&bus
->p
->subsys
.kobj
, &attr
->attr
);
131 drivers_autoprobe_show(struct bus_type
* bus
, char* buf
);
134 drivers_autoprobe_store(struct bus_type
* bus
, const char* buf
, size_t count
);
136 extern struct bus_attribute bus_attr_drivers_autoprobe
;
139 remove_probe_files(struct bus_type
* bus
)
141 bus_remove_file(bus
, &bus_attr_drivers_autoprobe
);
146 bus_unregister(struct bus_type
* bus
)
149 if (bus
->dev_root
) /* { dg-bogus "pointer 'bus' is dereferenced here" } */
150 device_unregister(bus
->dev_root
);
152 remove_probe_files(bus
);