xt_mp2t: use proper format specifiers for conn->id

First, since id is unsigned, we need %u. Second, I do not believe
uint32_t is necessary; just using unsigned int seems easier, as that
will save us lots of casts.
This commit is contained in:
Jan Engelhardt
2010-11-04 00:36:32 +01:00
parent 1d4b50b414
commit 91b61eaf08

View File

@@ -233,7 +233,7 @@ MODULE_PARM_DESC(msg_level, "Message level bit mask");
/*** Global defines ***/ /*** Global defines ***/
static DEFINE_SPINLOCK(mp2t_lock); /* Protects conn_htables list */ static DEFINE_SPINLOCK(mp2t_lock); /* Protects conn_htables list */
static LIST_HEAD(conn_htables); /* List of xt_rule_mp2t_conn_htable's */ static LIST_HEAD(conn_htables); /* List of xt_rule_mp2t_conn_htable's */
static u_int32_t GLOBAL_ID; /* Used for assigning rule_id's */ static unsigned int GLOBAL_ID; /* Used for assigning rule_id's */
/* TODO/FIXME: xt_hashlimit has this extra mutex, do I need it? /* TODO/FIXME: xt_hashlimit has this extra mutex, do I need it?
static DEFINE_MUTEX(mp2t_mutex);*/ /* Additional checkentry protection */ static DEFINE_MUTEX(mp2t_mutex);*/ /* Additional checkentry protection */
@@ -305,7 +305,7 @@ struct xt_rule_mp2t_conn_htable {
*/ */
struct list_head list; /* global list of all htables */ struct list_head list; /* global list of all htables */
atomic_t use; /* reference counting */ atomic_t use; /* reference counting */
u_int32_t id; /* id corrosponding to rule_id */ unsigned int id; /* id corrosponding to rule_id */
/* u_int8_t family; */ /* needed for IPv6 support */ /* u_int8_t family; */ /* needed for IPv6 support */
/* "cfg" is also defined here as the real hash array size might /* "cfg" is also defined here as the real hash array size might
@@ -351,7 +351,7 @@ mp2t_htable_create(struct xt_mp2t_mtinfo *minfo)
unsigned int hash_struct_sz; unsigned int hash_struct_sz;
char rule_name[IFNAMSIZ+5]; char rule_name[IFNAMSIZ+5];
unsigned int i; unsigned int i;
u_int32_t id; unsigned int id;
size_t size; size_t size;
/* Q: is lock with mp2t_lock necessary */ /* Q: is lock with mp2t_lock necessary */
@@ -367,12 +367,12 @@ mp2t_htable_create(struct xt_mp2t_mtinfo *minfo)
hash_struct_sz = sizeof(*minfo->hinfo); /* metadata struct size */ hash_struct_sz = sizeof(*minfo->hinfo); /* metadata struct size */
size = hash_struct_sz + sizeof(struct list_head) * hash_buckets; size = hash_struct_sz + sizeof(struct list_head) * hash_buckets;
msg_info(IFUP, "Alloc htable(%d) %d bytes elems:%d metadata:%d bytes", msg_info(IFUP, "Alloc htable(%u) %d bytes elems:%d metadata:%d bytes",
id, (int)size, hash_buckets, hash_struct_sz); id, (int)size, hash_buckets, hash_struct_sz);
hinfo = kzalloc(size, GFP_ATOMIC); hinfo = kzalloc(size, GFP_ATOMIC);
if (hinfo == NULL) { if (hinfo == NULL) {
msg_err(DRV, "unable to create hashtable(%d), out of memory!", msg_err(DRV, "unable to create hashtable(%u), out of memory!",
id); id);
return false; return false;
} }
@@ -418,7 +418,7 @@ mp2t_htable_create(struct xt_mp2t_mtinfo *minfo)
/* Generate a rule_name for proc if none given */ /* Generate a rule_name for proc if none given */
if (!minfo->rule_name || !strlen(minfo->rule_name)) if (!minfo->rule_name || !strlen(minfo->rule_name))
snprintf(rule_name, IFNAMSIZ+5, "rule_%d", hinfo->id); snprintf(rule_name, IFNAMSIZ+5, "rule_%u", hinfo->id);
else else
/* FIXME: Check for duplicate names! */ /* FIXME: Check for duplicate names! */
snprintf(rule_name, IFNAMSIZ+5, "rule_%s", minfo->rule_name); snprintf(rule_name, IFNAMSIZ+5, "rule_%s", minfo->rule_name);
@@ -597,7 +597,7 @@ mp2t_stream_alloc_init(struct xt_rule_mp2t_conn_htable *ht,
if (unlikely(ht->warn_condition < 10)) { if (unlikely(ht->warn_condition < 10)) {
ht->warn_condition++; ht->warn_condition++;
msg_warn(RX_ERR, msg_warn(RX_ERR,
"Rule[%d]: " "Rule[%u]: "
"Stopped tracking streams, max %u exceeded (%u) " "Stopped tracking streams, max %u exceeded (%u) "
"(Max can be adjusted via --max-streams param)", "(Max can be adjusted via --max-streams param)",
ht->id, ht->cfg.max, ht->count); ht->id, ht->cfg.max, ht->count);
@@ -676,7 +676,7 @@ xt_mp2t_mt_check(const struct xt_mtchk_param *par)
* conn_htable_destroy() thus not deallocating our memory */ * conn_htable_destroy() thus not deallocating our memory */
if (info->hinfo != NULL) { if (info->hinfo != NULL) {
atomic_inc(&info->hinfo->use); atomic_inc(&info->hinfo->use);
msg_info(DEBUG, "ReUsing info->hinfo ptr:[%p] htable id:%d", msg_info(DEBUG, "ReUsing info->hinfo ptr:[%p] htable id:%u",
info->hinfo, info->hinfo->id); info->hinfo, info->hinfo->id);
return 0; return 0;
} }
@@ -725,7 +725,7 @@ conn_htable_destroy(struct xt_rule_mp2t_conn_htable *ht)
/* Remove proc entry */ /* Remove proc entry */
remove_proc_entry(ht->pde->name, mp2t_procdir); remove_proc_entry(ht->pde->name, mp2t_procdir);
msg_info(IFDOWN, "Destroy stream elements (%d count) in htable(%d)", msg_info(IFDOWN, "Destroy stream elements (%d count) in htable(%u)",
ht->count, ht->id); ht->count, ht->id);
msg_dbg(IFDOWN, "Find stream, not found %d times", msg_dbg(IFDOWN, "Find stream, not found %d times",
ht->stream_not_found); ht->stream_not_found);
@@ -752,7 +752,7 @@ conn_htable_destroy(struct xt_rule_mp2t_conn_htable *ht)
spin_unlock(&ht->lock); spin_unlock(&ht->lock);
msg_info(IFDOWN, msg_info(IFDOWN,
"Free htable(%d) (%d buckets) longest list search %d", "Free htable(%u) (%d buckets) longest list search %d",
ht->id, ht->cfg.size, ht->max_list_search); ht->id, ht->cfg.size, ht->max_list_search);
if (ht->count != 0) if (ht->count != 0)
@@ -984,7 +984,7 @@ dissect_mp2t(unsigned char *payload_ptr, u16 payload_len,
} }
/* msg_info(RX_STATUS, */ /* msg_info(RX_STATUS, */
printk(KERN_INFO printk(KERN_INFO
"Rule:%d New stream (%pI4 -> %pI4)\n", "Rule:%u New stream (%pI4 -> %pI4)\n",
hinfo->id, &iph->saddr, &iph->daddr); hinfo->id, &iph->saddr, &iph->daddr);
} }
@@ -1291,7 +1291,7 @@ static int mp2t_seq_show(struct seq_file *s, void *v)
/* dynamic info */ /* dynamic info */
seq_puts(s, "# info:dynamic"); seq_puts(s, "# info:dynamic");
seq_printf(s, " rule_id:%d", htable->id); seq_printf(s, " rule_id:%u", htable->id);
seq_printf(s, " streams:%d", htable->count); seq_printf(s, " streams:%d", htable->count);
seq_printf(s, " streams_check:%d", htable->stream_not_found); seq_printf(s, " streams_check:%d", htable->stream_not_found);
seq_printf(s, " max_list_search:%d", htable->max_list_search); seq_printf(s, " max_list_search:%d", htable->max_list_search);