Commit 55ac9f8d authored by Luis R. Rodriguez's avatar Luis R. Rodriguez

Double pointers obfuscate code, die

Lets make country2rd() easier to read by not using
double pointers.
Signed-off-by: 's avatarLuis R. Rodriguez <lrodriguez@atheros.com>
parent 84ff22a5
......@@ -76,8 +76,9 @@ int main(int argc, char **argv)
for (i = 0; i < num_countries; i++) {
struct regdb_file_reg_country *country = countries + i;
r = country2rd(db, dblen, country, &rd);
if (r) {
rd = country2rd(db, dblen, country);
if (!rd) {
r = -ENOMEM;
fprintf(stderr, "Could not covert country "
"(%.2s) to rd\n", country->alpha2);
goto out;
......
......@@ -158,9 +158,8 @@ void reg_rule2rd(__u8 *db, int dblen,
}
/* Converts a file regdomain to ieee80211_regdomain, easier to manage */
int country2rd(__u8 *db, int dblen,
struct regdb_file_reg_country *country,
struct ieee80211_regdomain **rdp)
struct ieee80211_regdomain *country2rd(__u8 *db, int dblen,
struct regdb_file_reg_country *country)
{
struct regdb_file_reg_rules_collection *rcoll;
struct ieee80211_regdomain *rd;
......@@ -177,11 +176,9 @@ int country2rd(__u8 *db, int dblen,
size_of_rd = sizeof(struct ieee80211_regdomain) +
num_rules * sizeof(struct ieee80211_reg_rule);
*rdp = malloc(size_of_rd);
if (!*rdp)
return -ENOMEM;
rd = *rdp;
rd = malloc(size_of_rd);
if (!rd)
return NULL;
memset(rd, 0, size_of_rd);
......@@ -194,7 +191,7 @@ int country2rd(__u8 *db, int dblen,
&rd->reg_rules[i]);
}
return 0;
return rd;
}
/* Sanity check on a regulatory rule */
......
......@@ -90,9 +90,8 @@ 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);
int country2rd(__u8 *db, int dblen,
struct regdb_file_reg_country *country,
struct ieee80211_regdomain **rdp);
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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment