diff mbox

Fix build on older compilers that do not support 'd' suffix.

Message ID 1376503171-25879-1-git-send-email-greearb@candelatech.com
State Rejected
Headers show

Commit Message

Ben Greear Aug. 14, 2013, 5:59 p.m. UTC
From: Ben Greear <greearb@candelatech.com>

Things like:  if (foo > 0.0d) { }
fails to compile on Fedora 13 (at least) because the compiler
does not support a 'd' suffix properly.

Use a slightly uglier explicit cast to double to work around
this compiler limitation.

Signed-hostap: Ben Greear <greearb@candelatech.com>
---
 hostapd/config_file.c |    4 ++--
 src/ap/ap_config.c    |   10 +++++-----
 src/ap/beacon.c       |    2 +-
 src/ap/ieee802_11.c   |    6 +++---
 src/ap/wpa_auth.c     |    2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)

Comments

Jouni Malinen Aug. 31, 2013, 2:03 p.m. UTC | #1
On Wed, Aug 14, 2013 at 10:59:31AM -0700, greearb@candelatech.com wrote:
> Things like:  if (foo > 0.0d) { }
> fails to compile on Fedora 13 (at least) because the compiler
> does not support a 'd' suffix properly.
> 
> Use a slightly uglier explicit cast to double to work around
> this compiler limitation.

These are all pretty ugly and in code that is not normally built in. Do
we really care about Fedora 13 that had its end-of-life two years ago? I
could understand this for areas that would be included by default in the
compilation or for some more common use cases, but none of the modified
places here seemed to qualify for that.
Ben Greear Aug. 31, 2013, 3:41 p.m. UTC | #2
On 08/31/2013 07:03 AM, Jouni Malinen wrote:
> On Wed, Aug 14, 2013 at 10:59:31AM -0700, greearb@candelatech.com wrote:
>> Things like:  if (foo > 0.0d) { }
>> fails to compile on Fedora 13 (at least) because the compiler
>> does not support a 'd' suffix properly.
>>
>> Use a slightly uglier explicit cast to double to work around
>> this compiler limitation.
>
> These are all pretty ugly and in code that is not normally built in. Do
> we really care about Fedora 13 that had its end-of-life two years ago? I
> could understand this for areas that would be included by default in the
> compilation or for some more common use cases, but none of the modified
> places here seemed to qualify for that.

I figured that there might be other embedded systems using older compilers
that might benefit from this.

Not a big deal though.

Thanks,
Ben
diff mbox

Patch

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index e9d324f..59f3798 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -2898,8 +2898,8 @@  static int hostapd_config_fill(struct hostapd_config *conf,
 			char *end;					\
 									\
 			conf->_val = strtod(pos, &end);			\
-			if (*end || conf->_val < 0.0d ||		\
-			    conf->_val > 1.0d) {			\
+			if (*end || conf->_val < (double)(0.0) ||	\
+			    conf->_val > (double)(1.0)) {		\
 				wpa_printf(MSG_ERROR,			\
 					   "Line %d: Invalid value '%s'", \
 					   line, pos);			\
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index 54a2e75..92bdd0d 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -164,11 +164,11 @@  struct hostapd_config * hostapd_config_defaults(void)
 	conf->ap_table_expiration_time = 60;
 
 #ifdef CONFIG_TESTING_OPTIONS
-	conf->ignore_probe_probability = 0.0d;
-	conf->ignore_auth_probability = 0.0d;
-	conf->ignore_assoc_probability = 0.0d;
-	conf->ignore_reassoc_probability = 0.0d;
-	conf->corrupt_gtk_rekey_mic_probability = 0.0d;
+	conf->ignore_probe_probability = (double)(0.0);
+	conf->ignore_auth_probability = (double)(0.0);
+	conf->ignore_assoc_probability = (double)(0.0);
+	conf->ignore_reassoc_probability = (double)(0.0);
+	conf->corrupt_gtk_rekey_mic_probability = (double)(0.0);
 #endif /* CONFIG_TESTING_OPTIONS */
 
 	return conf;
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 2f4ba23..ad27565 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -500,7 +500,7 @@  void handle_probe_req(struct hostapd_data *hapd,
 	 * with AP configuration */
 
 #ifdef CONFIG_TESTING_OPTIONS
-	if (hapd->iconf->ignore_probe_probability > 0.0d &&
+	if (hapd->iconf->ignore_probe_probability > (double)(0.0) &&
 	    drand48() < hapd->iconf->ignore_probe_probability) {
 		wpa_printf(MSG_INFO,
 			   "TESTING: ignoring probe request from " MACSTR,
diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 35282af..5272b0c 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -558,7 +558,7 @@  static void handle_auth(struct hostapd_data *hapd,
 	}
 
 #ifdef CONFIG_TESTING_OPTIONS
-	if (hapd->iconf->ignore_auth_probability > 0.0d &&
+	if (hapd->iconf->ignore_auth_probability > (double)(0.0) &&
 	    drand48() < hapd->iconf->ignore_auth_probability) {
 		wpa_printf(MSG_INFO,
 			   "TESTING: ignoring auth frame from " MACSTR,
@@ -1237,7 +1237,7 @@  static void handle_assoc(struct hostapd_data *hapd,
 
 #ifdef CONFIG_TESTING_OPTIONS
 	if (reassoc) {
-		if (hapd->iconf->ignore_reassoc_probability > 0.0d &&
+		if (hapd->iconf->ignore_reassoc_probability > (double)(0.0) &&
 		    drand48() < hapd->iconf->ignore_reassoc_probability) {
 			wpa_printf(MSG_INFO,
 				   "TESTING: ignoring reassoc request from "
@@ -1245,7 +1245,7 @@  static void handle_assoc(struct hostapd_data *hapd,
 			return;
 		}
 	} else {
-		if (hapd->iconf->ignore_assoc_probability > 0.0d &&
+		if (hapd->iconf->ignore_assoc_probability > (double)(0.0) &&
 		    drand48() < hapd->iconf->ignore_assoc_probability) {
 			wpa_printf(MSG_INFO,
 				   "TESTING: ignoring assoc request from "
diff --git a/src/ap/wpa_auth.c b/src/ap/wpa_auth.c
index 25e4a43..95bc17d 100644
--- a/src/ap/wpa_auth.c
+++ b/src/ap/wpa_auth.c
@@ -1349,7 +1349,7 @@  void __wpa_send_eapol(struct wpa_authenticator *wpa_auth,
 				  key->key_mic);
 #ifdef CONFIG_TESTING_OPTIONS
 		if (!pairwise &&
-		    wpa_auth->conf.corrupt_gtk_rekey_mic_probability > 0.0d &&
+		    wpa_auth->conf.corrupt_gtk_rekey_mic_probability > (double)(0.0) &&
 		    drand48() <
 		    wpa_auth->conf.corrupt_gtk_rekey_mic_probability) {
 			wpa_auth_logger(wpa_auth, sm->addr, LOGGER_INFO,