IRA: Ignore debug insns for uses in split_live_ranges_for_shrink_wrap. [PR116179]
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / deref-before-check-pr109239-linux-bus.c
blobadd7731c6b0000953abae27c32203525466041cc
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;
12 struct list_head
14 struct list_head *next, *prev;
17 struct kobject
19 /* [...snip...] */
22 struct attribute
24 /* [...snip...] */
27 static inline
28 void
29 sysfs_remove_file_ns(struct kobject* kobj,
30 const struct attribute* attr,
31 const void* ns)
35 static inline
36 void
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);
45 extern void
46 kobject_put(struct kobject* kobj);
48 struct kset
50 struct list_head list;
51 /* [...snip...] */
52 struct kobject kobj;
53 /* [...snip...] */
54 } __attribute__((__designated_init__));
56 static inline
57 struct kset*
58 to_kset(struct kobject* kobj)
60 return kobj ? ({
61 char* __mptr = (char*)(kobj);
62 ((struct kset*)(__mptr - __builtin_offsetof(struct kset, kobj)));
63 }) : NULL;
66 static inline
67 struct kset*
68 kset_get(struct kset* k)
70 return k ? to_kset(kobject_get(&k->kobj)) : NULL;
73 static inline
74 void
75 kset_put(struct kset* k)
77 kobject_put(&k->kobj);
80 struct bus_type
82 /* [...snip...] */
83 struct device* dev_root;
84 /* [...snip...] */
85 struct subsys_private* p;
86 /* [...snip...] */
89 struct bus_attribute
91 struct attribute attr;
92 /* [...snip...] */
95 extern void
96 device_unregister(struct device* dev);
98 struct subsys_private
100 struct kset subsys;
101 /* [...snip...] */
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);
109 return bus;
111 return NULL;
114 static void
115 bus_put(struct bus_type* bus)
117 if (bus)
118 kset_put(&bus->p->subsys);
121 void
122 bus_remove_file(struct bus_type* bus, struct bus_attribute* attr)
124 if (bus_get(bus)) {
125 sysfs_remove_file(&bus->p->subsys.kobj, &attr->attr);
126 bus_put(bus);
130 extern ssize_t
131 drivers_autoprobe_show(struct bus_type* bus, char* buf);
133 extern ssize_t
134 drivers_autoprobe_store(struct bus_type* bus, const char* buf, size_t count);
136 extern struct bus_attribute bus_attr_drivers_autoprobe;
138 static void
139 remove_probe_files(struct bus_type* bus)
141 bus_remove_file(bus, &bus_attr_drivers_autoprobe);
142 /* [...snip...] */
145 void
146 bus_unregister(struct bus_type* bus)
148 /* [...snip...] */
149 if (bus->dev_root) /* { dg-bogus "pointer 'bus' is dereferenced here" } */
150 device_unregister(bus->dev_root);
151 /* [...snip...] */
152 remove_probe_files(bus);
153 /* [...snip...] */