Get rid of unpleasant cast, it causes SIGSEGV
authorMarcin Cieslak <saper@saper.info>
Mon, 24 Sep 2012 11:36:13 +0000 (13:36 +0200)
committerJon Trulson <jon@radscan.com>
Tue, 25 Sep 2012 00:25:28 +0000 (18:25 -0600)
Having a difficult choice between unplasant
cast to get a void * into an enumeration type
and "Something's wrong here" double cast
I decided for the latter.

At least it does not crash when the legal
value of zero is passed as the argument.

cde/programs/dtmail/dtmail/DmxPrintOptions.C

index 15011af2037aa742c1c079924173e9cf55050d78..306f1da13e6c2592e9bb87f035b34a84eadd205b 100644 (file)
@@ -672,11 +672,8 @@ DmxPrintOptions::isValidMarginSpec(PropUiItem* pui, void* data)
     char       *marginSpec = NULL;
     XtEnum     parseError;
     Widget     text;
-#if defined(linux) || defined(CSRG_BASED)
-    _DtPrintMarginEnum which = *((_DtPrintMarginEnum *) data);
-#else
-    _DtPrintMarginEnum which = (_DtPrintMarginEnum) data;
-#endif
+
+    _DtPrintMarginEnum which = (_DtPrintMarginEnum)(long)data;
 
     text = pui->getWidget();
     if (text)