summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall/sysinstall.h
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2001-07-02 00:18:04 +0000
committerdd <dd@FreeBSD.org>2001-07-02 00:18:04 +0000
commit4a798fb83a60241d607536db8b69d9709995a803 (patch)
treeeb3e6d3ae80fce772bbe283df44e815263d1b83f /usr.sbin/sysinstall/sysinstall.h
parentb1763d41ddf8b57a46b69e3e8423b9d57392bd6a (diff)
downloadFreeBSD-src-4a798fb83a60241d607536db8b69d9709995a803.zip
FreeBSD-src-4a798fb83a60241d607536db8b69d9709995a803.tar.gz
Introduce DEVICE_INIT, DEVICE_GET, and DEVICE_SHUTDOWN macros. As the
names suggest, they perform methods on Device's. In addition, they check that the pointer passed to them is valid; if it isn't, they pretend that the action failed. This fixes some crashes due to NULL dereferences (e.g., PR 26509). Approved by: jkh (some time ago)
Diffstat (limited to 'usr.sbin/sysinstall/sysinstall.h')
-rw-r--r--usr.sbin/sysinstall/sysinstall.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/usr.sbin/sysinstall/sysinstall.h b/usr.sbin/sysinstall/sysinstall.h
index b8cf0e1..0f8fd75 100644
--- a/usr.sbin/sysinstall/sysinstall.h
+++ b/usr.sbin/sysinstall/sysinstall.h
@@ -770,5 +770,12 @@ extern int dump_variables(dialogMenuItem *self);
/* wizard.c */
extern void slice_wizard(Disk *d);
+/*
+ * Macros. Please find a better place for us!
+ */
+#define DEVICE_INIT(d) ((d) != NULL ? (d)->init((d)) : NULL)
+#define DEVICE_GET(d, b, f) ((d) != NULL ? (d)->get((d), (b), (f)) : NULL)
+#define DEVICE_SHUTDOWN(d) ((d) != NULL ? (d)->shutdown((d)) : (void)0)
+
#endif
/* _SYSINSTALL_H_INCLUDE */
OpenPOWER on IntegriCloud