// 4096 bytes default buffer should save us from reallocations
// as it fits 200 concurrent active clients
- if ((ctx->data = malloc(IPT_ACCOUNT_MIN_BUFSIZE)) == NULL) {
+ ctx->data = malloc(IPT_ACCOUNT_MIN_BUFSIZE);
+ if (ctx->data == NULL) {
close(ctx->sockfd);
ctx->sockfd = -1;
ctx->error_str = "Out of memory for data buffer";
dest->itemcount = ipt_acc_tables[table_nr].itemcount;
/* allocate "root" table */
- if ((dest->data = ipt_acc_zalloc_page()) == NULL) {
+ dest->data = ipt_acc_zalloc_page();
+ if (dest->data == NULL) {
printk("ACCOUNT: out of memory for root table "
"in ipt_acc_handle_prepare_read()\n");
return -1;
}
/* Try to allocate memory */
- if (!(new_data_page = ipt_acc_zalloc_page())) {
+ new_data_page = ipt_acc_zalloc_page();
+ if (new_data_page == NULL) {
printk("ACCOUNT: ipt_acc_handle_prepare_read_flush(): "
"Out of memory!\n");
return -1;
/* Allocate a userspace handle */
down(&ian->ipt_acc_userspace_mutex);
- if ((handle.handle_nr = ipt_acc_handle_find_slot(ian->ipt_acc_handles)) == -1) {
+ handle.handle_nr = ipt_acc_handle_find_slot(ian->ipt_acc_handles);
+ if (handle.handle_nr == -1) {
ipt_acc_data_free(dest.data, dest.depth);
up(&ian->ipt_acc_userspace_mutex);
return -EINVAL;
void *subnets;
struct stat sb;
char buf[256];
- int fd;
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int n;
#endif
else
snprintf(buf, sizeof(buf), GEOIP_DB_DIR "/%s.iv4", code);
- if ((fd = open(buf, O_RDONLY)) < 0) {
+ int fd = open(buf, O_RDONLY);
+ if (fd < 0) {
fprintf(stderr, "Could not open %s: %s\n", buf, strerror(errno));
xtables_error(OTHER_PROBLEM, "Could not read geoip database");
}
next = strchr(cp, ',');
if (next) *next++ = '\0';
- if ((cctmp = check_geoip_cc(cp, cc, count)) != 0) {
+ cctmp = check_geoip_cc(cp, cc, count);
+ if (cctmp != 0) {
if ((mem[count++].user =
(unsigned long)geoip_load_cc(cp, cctmp, nfproto)) == 0)
xtables_error(OTHER_PROBLEM,
static const char *
check_proto(uint16_t pnum, uint8_t invflags)
{
- char *proto;
-
if (invflags & XT_INV_PROTO)
xtables_error(PARAMETER_PROBLEM, PKNOCK "only works with TCP and UDP.");
- if ((proto = proto_to_name(pnum)) != NULL)
+ const char *proto = proto_to_name(pnum);
+ if (proto != NULL)
return proto;
else if (pnum == 0)
xtables_error(PARAMETER_PROBLEM, PKNOCK "needs `-p tcp' or `-p udp'");
struct xt_pknock_nl_msg *pknock_msg;
if (argc > 2) {
- char *prog;
- if (!(prog = strdup(argv[0]))) {
+ char *prog = strdup(argv[0]);
+ if (prog == NULL) {
perror("strdup()");
} else {
fprintf(stderr, "%s [ group-id ]\n", basename(prog));
/* Sets, updates, removes or checks the peer matching status. */
if (info->option & XT_PKNOCK_KNOCKPORT) {
- if ((ret = is_allowed(peer))) {
+ ret = is_allowed(peer);
+ if (ret != 0) {
if (info->option & XT_PKNOCK_CLOSESECRET &&
(iph->protocol == IPPROTO_UDP ||
iph->protocol == IPPROTO_UDPLITE))
printk(KERN_WARNING PFX "Warning: Could not find or load "
"\"DELUDE\" target\n");
- if ((ret = xt_register_target(&chaos_tg_reg)) != 0) {
+ ret = xt_register_target(&chaos_tg_reg);
+ if (ret != 0) {
printk(KERN_WARNING PFX "xt_register_target returned "
"error %d\n", ret);
goto out3;
return false;
/* Check for invalid packets: -m conntrack --ctstate INVALID */
- if ((ctdata = nf_ct_get(skb, &ctstate)) == NULL) {
+ ctdata = nf_ct_get(skb, &ctstate);
+ if (ctdata == NULL) {
if (info->match_stealth)
return lscan_mt_stealth(tcph);
/*