Skip to contentSkip to conversation

Code fixups and optimisation

PATCH Applied Diego 'Flameeyes' Pettenò 2 participants 5 messages Dec 1, 2008

lore
Share & tools
lore
#0 lore raw

cover Code fixups and optimisation

After fixing the Makefile I have taken a look at the actual code, just three simple patches for that.

---

Diego 'Flameeyes' Petten=C3=B2 (3):
Avoid implicit declaration of memset() with OpenSSL. Mark constant the generated key tables for libgcrypt. Mark functions static when not used outside their translation uni=
t.

 intersect.c      |    2 +-
 reglib.c         |    5 +++--
 reglib.h         |    3 ---
 utils/key2pub.py |    6 +++---
 4 files changed, 7 insertions(+), 9 deletions(-)

--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#1 lore raw

PATCH 1/3 Mark functions static when not used outside their translation unit.

---

 intersect.c |    2 +-
 reglib.c    |    4 ++--
 reglib.h    |    3 ---
 3 files changed, 3 insertions(+), 6 deletions(-)
intersect.c +1 -1
index 279d807..d6d857d 100644
@@ -75,7 +75,7 @@ static int reg_rules_intersect(
  * resulting intersection of rules between rd1 and rd2. We will
  * malloc() this structure for you.
  */
-struct ieee80211_regdomain *regdom_intersect(
+static struct ieee80211_regdomain *regdom_intersect(
 	struct ieee80211_regdomain *rd1,
 	struct ieee80211_regdomain *rd2)
 {
reglib.c +2 -2
index e6b9b3f..c173818 100644
@@ -133,7 +133,7 @@ out:
 #endif
 }
 
-void reg_rule2rd(__u8 *db, int dblen,
+static void reg_rule2rd(__u8 *db, int dblen,
 	__be32 ruleptr, struct ieee80211_reg_rule *rd_reg_rule)
 {
 	struct regdb_file_reg_rule *rule;
@@ -214,7 +214,7 @@ int is_valid_reg_rule(const struct ieee80211_reg_rule *rule)
 	return 1;
 }
 
-void print_reg_rule(struct ieee80211_reg_rule *rule)
+static void print_reg_rule(struct ieee80211_reg_rule *rule)
 {
 	struct ieee80211_freq_range *freq;
 	struct ieee80211_power_rule *power;
reglib.h +0 -3
index 65e0ad6..095090b 100644
@@ -88,14 +88,11 @@ void *crda_get_file_ptr(__u8 *db, int dblen, int structlen, __be32 ptr);
 int crda_verify_db_signature(__u8 *db, int dblen, int siglen);
 
 /* File reg db entry -> rd converstion utilities */
-void reg_rule2rd(__u8 *db, int dblen,
-	__be32 ruleptr, struct ieee80211_reg_rule *rd_reg_rule);
 struct ieee80211_regdomain *country2rd(__u8 *db, int dblen,
 	struct regdb_file_reg_country *country);
 
 /* reg helpers */
 int is_valid_reg_rule(const struct ieee80211_reg_rule *rule);
-void print_reg_rule(struct ieee80211_reg_rule *rule);
 void print_regdom(struct ieee80211_regdomain *rd);
 
 #endif
#2 lore raw

PATCH 2/3 Mark constant the generated key tables for libgcrypt.

In reply to Diego 'Flameeyes' Pettenò

Since they are never modified, mark the key tables constant so they are emitted in .rodata.

Note that even though they are probably also never modified, the OpenSSL tables generate warnings when they are marked constant, as such they are untouched.
---

 utils/key2pub.py |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
utils/key2pub.py +3 -3
index 8cd9596..bc1d33d 100755
@@ -50,7 +50,7 @@ static struct pubkey keys[] = {
 def print_gcrypt(name, val):
     while val[0] == '\0':
         val = val[1:]
-    sys.stdout.write('static __u8 %s[%d] = {\n' % (name, len(val)))
+    sys.stdout.write('static const __u8 %s[%d] = {\n' % (name, len(val)))
     idx = 0
     for v in val:
         if not idx:
@@ -67,7 +67,7 @@ def print_gcrypt(name, val):
 def print_gcrypt_keys(n):
     sys.stdout.write(r'''
 struct key_params {
-	__u8 *e, *n;
+	const __u8 *e, *n;
 	__u32 len_e, len_n; 
 };
 
@@ -76,7 +76,7 @@ struct key_params {
 	.n = _n, .len_n = sizeof(_n),	\
 }
 
-static struct key_params keys[] = {
+static const struct key_params keys[] = {
 ''')
     for n in xrange(n + 1):
         sys.stdout.write('	KEYS(e_%d, n_%d),\n' % (n, n))
#3 lore raw

PATCH 3/3 Avoid implicit declaration of memset() with OpenSSL.

In reply to Diego 'Flameeyes' Pettenò

When building the libgcrypt-based code, string.h is included through libgcrypt itself, but when building with OpenSSL it's missing.

Include it explicitly so that it's always safe.
---

 reglib.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
reglib.c +1 -0
index c173818..2f10d23 100644
@@ -1,5 +1,6 @@
 #include <errno.h>
 #include <stdio.h>
+#include <string.h>
 #include <arpa/inet.h>
 #include "reglib.h"
 
#4 lore raw
In reply to Diego 'Flameeyes' Pettenò

On Mon, Dec 01, 2008 at 03:11:08AM -0800, Diego 'Flameeyes' Petten=F2 w= rote:

Quoted 1 line

After fixing the Makefile I have taken a look at the actual code, jus=

t

Quoted 1 line

three simple patches for that.

Thanks, applied.

Luis
--
To unsubscribe from this list: send the line "unsubscribe linux-wireles= s" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html