unsigned int i;
buffer = strdup(portstring);
- if (!buffer) xtables_error(OTHER_PROBLEM, "strdup failed");
+ if (buffer == NULL)
+ xtables_error(OTHER_PROBLEM, "strdup failed");
- for (cp=buffer, i=0; cp && i<IPT_PKNOCK_MAX_PORTS; cp=next, i++)
+ for (cp=buffer, i=0; cp != NULL && i<IPT_PKNOCK_MAX_PORTS; cp=next, i++)
{
next=strchr(cp, ',');
- if (next) *next++='\0';
+ if (next != NULL)
+ *next++ = '\0';
ports[i] = xtables_parse_port(cp, proto);
}
- if (cp) xtables_error(PARAMETER_PROBLEM, "too many ports specified");
+ if (cp != NULL)
+ xtables_error(PARAMETER_PROBLEM, "too many ports specified");
free(buffer);
return i;
if ((proto = proto_to_name(pnum)) != NULL)
return proto;
- else if (!pnum)
+ else if (pnum == 0)
xtables_error(PARAMETER_PROBLEM, PKNOCK "needs `-p tcp' or `-p udp'");
else
xtables_error(PARAMETER_PROBLEM, PKNOCK "only works with TCP and UDP.");
pknock_proc_open(struct inode *inode, struct file *file)
{
int ret = seq_open(file, &pknock_seq_ops);
- if (!ret) {
+ if (ret == 0) {
struct seq_file *sf = file->private_data;
sf->private = PDE(inode);
}
static inline bool
is_time_exceeded(const struct peer *peer, unsigned int max_time)
{
- return peer && time_after(jiffies/HZ, peer->timestamp + max_time);
+ return peer != NULL && time_after(jiffies / HZ,
+ peer->timestamp + max_time);
}
/**
static inline bool
has_logged_during_this_minute(const struct peer *peer)
{
- return peer && (peer->login_min == get_epoch_minute());
+ return peer != NULL && peer->login_min == get_epoch_minute();
}
/**
rule->timer.data = (unsigned long)rule;
rule->status_proc = create_proc_entry(info->rule_name, 0, pde);
- if (!rule->status_proc) {
+ if (rule->status_proc == NULL) {
printk(KERN_ERR PKNOCK "create_proc_entry() error in add_rule()"
" function.\n");
kfree(rule);
pr_debug("(N) rule not found: %s.\n", info->rule_name);
return;
}
- if (rule && rule->ref_count == 0) {
+ if (rule != NULL && rule->ref_count == 0) {
hashtable_for_each_safe(pos, n, rule->peer_head, peer_hashsize, i) {
peer = list_entry(pos, struct peer, head);
}
}
- if (rule->status_proc)
+ if (rule->status_proc != NULL)
remove_proc_entry(info->rule_name, pde);
pr_debug("(D) rule deleted: %s.\n", rule->rule_name);
if (timer_pending(&rule->timer))
remove_peer(struct peer *peer)
{
list_del(&peer->head);
- if (peer) kfree(peer);
+ if (peer != NULL)
+ kfree(peer);
}
/**
is_wrong_knock(const struct peer *peer, const struct ipt_pknock *info,
uint16_t port)
{
- return peer && (info->port[peer->id_port_knocked-1] != port);
+ return peer != NULL && info->port[peer->id_port_knocked-1] != port;
}
/**
static inline bool
is_last_knock(const struct peer *peer, const struct ipt_pknock *info)
{
- return peer && (peer->id_port_knocked-1 == info->ports_count);
+ return peer != NULL && peer->id_port_knocked - 1 == info->ports_count;
}
/**
static inline bool
is_allowed(const struct peer *peer)
{
- return peer && (peer->status == ST_ALLOWED);
+ return peer != NULL && peer->status == ST_ALLOWED;
}
/**
struct ipt_pknock_nl_msg msg;
m = kmalloc(sizeof(*m) + sizeof(msg), GFP_ATOMIC);
- if (!m) {
+ if (m == NULL) {
printk(KERN_ERR PKNOCK "kmalloc() error in "
"msg_to_userspace_nl().\n");
return false;
sg_set_buf(&sg[1], &epoch_min, sizeof(epoch_min));
ret = crypto_hash_setkey(crypto.tfm, secret, secret_len);
- if (ret) {
+ if (ret != 0) {
printk("crypto_hash_setkey() failed ret=%d\n", ret);
ret = 0;
goto out;
* 4 bytes int epoch_min (32 bits)
*/
ret = crypto_hash_digest(&crypto.desc, sg, 8, result);
- if (ret) {
+ if (ret != 0) {
printk("crypto_hash_digest() failed ret=%d\n", ret);
ret = 0;
goto out;
struct ipt_pknock *info = par->matchinfo;
/* Singleton. */
- if (!rule_hashtable) {
+ if (rule_hashtable == NULL) {
rule_hashtable = alloc_hashtable(rule_hashsize);
if (rule_hashtable == NULL)
RETURN_ERR("alloc_hashtable() error in checkentry()\n");