Re: [PATCH libmnl 1/2] socket: introduce mnl_socket_open2()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Oct 05, 2015 at 05:37:15PM +0200, Pablo Neira Ayuso wrote:
> On Fri, Oct 02, 2015 at 10:12:33PM +0200, Guillaume Nault wrote:
> > Define mnl_socket_open2() so that user can pass a set of SOCK_* flags
> > at socket creation time.
> > 
> > Signed-off-by: Guillaume Nault <g.nault@xxxxxxxxxxxx>
> > ---
> >  include/libmnl/libmnl.h |  3 ++-
> >  src/libmnl.map          |  1 +
> >  src/socket.c            | 41 ++++++++++++++++++++++++++++++++---------
> >  3 files changed, 35 insertions(+), 10 deletions(-)
> > 
> > diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
> > index 3a589bc..5adb13c 100644
> > --- a/include/libmnl/libmnl.h
> > +++ b/include/libmnl/libmnl.h
> > @@ -21,7 +21,8 @@ extern "C" {
> >  
> >  struct mnl_socket;
> >  
> > -extern struct mnl_socket *mnl_socket_open(int type);
> > +extern struct mnl_socket *mnl_socket_open(int bus);
> > +extern struct mnl_socket *mnl_socket_open2(int bus, int flags);
> 
> Looks good, but we should be using 'unsigned int flags' instead, right?
> 
> Or am I missing anything?

Generally speaking, I'd also consider unsigned integers to be more
appropriate for flag parameters.

But all socket() parameters are signed integers, including "type" which
is bitwise OR-ed with "flags". Furthermore, others libc's functions
introduced for the same purpose (race-free setting of CLOEXEC flag),
also use a signed integer as flag parameter (like dup3()).

So I've used int for consistency. But I can repost if you prefer.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux