All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [1/1] connector: add userspace example code into Documentation/connector/
Date: Fri, 25 Aug 2006 08:57:23 +0200	[thread overview]
Message-ID: <44EE9F53.2090303@trash.net> (raw)
In-Reply-To: <20060825064956.GA20468@2ka.mipt.ru>

Evgeniy Polyakov wrote:
> Hello.
> 
> I was asked several times to include userspace example code into
> Documentation, so if there is no policy against it, consider attached patch 
> for 2.6.18. This program works with included Documentation/connector/cn_test.c 
> connector module.

> +	l_local.nl_family = AF_NETLINK;
> +	l_local.nl_groups = 0x123;
> +	l_local.nl_pid = 0;
> +
> +	if (bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)) == -1) {
> +		perror("bind");
> +		close(s);
> +		return -1;
> +	}
> +
> +	{
> +		int on = l_local.nl_groups;
> +		setsockopt(s, 270, 1, &on, sizeof(on));
> +	}

Example code shouldn't use magic numbers, please use the proper defines.
And the code is wrong, using the same group number for bind (which takes
a bitmask) and setsockopt (which takes a group number) doesn't work.
Its not necessary to use setsockopt if you already used bind anyway.


  reply	other threads:[~2006-08-25  6:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-25  6:49 [1/1] connector: add userspace example code into Documentation/connector/ Evgeniy Polyakov
2006-08-25  6:57 ` Patrick McHardy [this message]
2006-08-25  7:05   ` Evgeniy Polyakov
2006-08-25  7:11     ` Evgeniy Polyakov
2006-08-25  7:13       ` Patrick McHardy
2006-08-25  7:52       ` David Miller
2006-08-25  8:15         ` Evgeniy Polyakov
2006-08-25  8:17           ` David Miller
2006-08-25  8:27             ` Evgeniy Polyakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44EE9F53.2090303@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=johnpol@2ka.mipt.ru \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.