NetBSD Problem Report #48560

From reed@reedmedia.net  Wed Jan 29 13:43:47 2014
Return-Path: <reed@reedmedia.net>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 171E1A6488
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 29 Jan 2014 13:43:46 +0000 (UTC)
Message-Id: <28655-1391003024@reedmedia.net>
Date: Wed, 29 Jan 2014 07:43:45 -0600
From: reed@reedmedia.net
Reply-To: reed@reedmedia.net
To: gnats-bugs@gnats.NetBSD.org
Subject: kevent.udata and void *
X-Send-Pr-Version: 3.95

>Number:         48560
>Category:       kern
>Synopsis:       kevent.udata and invalid conversion
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 29 13:45:00 +0000 2014
>Closed-Date:    Sun Jan 24 13:13:24 +0000 2021
>Last-Modified:  Sun Jan 24 13:13:24 +0000 2021
>Originator:     reed@reedmedia.net
>Release:        NetBSD 6
>Organization:
>Environment:
Architecture: x86_64
Machine: amd64
>Description:

For src/sys/sys/event.h

I am told that kevent.udata should maybe be void * since C++ doesn't 
allow the naive conversion from a pointer type to integer. Apparently 
some other systems have that has void *

error: invalid conversion from 'char*' to '__intptr_t'

I am not sure what prompted the change.
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/event.h.diff?r1=1.1.1.1.2.10&r2=1.1.1.1.2.11

See http://sourceforge.net/p/asio/git/ci/master/tree/asio/include/asio/detail/impl/kqueue_reactor.ipp
for an example of __NetBSD__ workaround.
>How-To-Repeat:

#include <sys/types.h>
#include <sys/param.h>
#include <sys/event.h>
#include <sys/time.h>
int main ()
{
  struct kevent ev;
  char* udata;
  EV_SET(&ev, 0, 0, 0, 0, 0, udata);
  return 0;
}

>Fix:
I don't know if ours is correct or not, but it behaves different than
MacOS and others.

>Release-Note:

>Audit-Trail:
From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, kern-bug-people@netbsd.org, 
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Cc: 
Subject: Re: kern/48560: kevent.udata and void *
Date: Wed, 29 Jan 2014 11:41:17 -0500

 On Jan 29,  1:45pm, reed@reedmedia.net (reed@reedmedia.net) wrote:
 -- Subject: kern/48560: kevent.udata and void *

 | For src/sys/sys/event.h
 | 
 | I am told that kevent.udata should maybe be void * since C++ doesn't 
 | allow the naive conversion from a pointer type to integer. Apparently 
 | some other systems have that has void *
 | 
 | error: invalid conversion from 'char*' to '__intptr_t'
 | 
 | I am not sure what prompted the change.
 | http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/event.h.diff?r1=1.1.1.1.2.10&r2=1.1.1.1.2.11
 | 
 | See http://sourceforge.net/p/asio/git/ci/master/tree/asio/include/asio/detail/impl/kqueue_reactor.ipp
 | for an example of __NetBSD__ workaround.

 I believe this was done deliberately so that the "opaque user
 identifier" was not just a pointer but an integer type (to indicate
 that this does not necessary hold a pointer but it *can* hold one).
 Nevertheless the reinterpret_cast<type *>(e->udata) takes care of
 the issue. In C++ need a static_cast anyway since "void *" is not
 fungible with other pointers (unless of course you are assigning to
 "void *".

 christos

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: kern/48560: kevent.udata and void *
Date: Wed, 29 Jan 2014 17:52:58 +0100

 See also the thread at 

   http://mail-index.netbsd.org/current-users/2012/11/10/msg021459.html

 Martin

State-Changed-From-To: open->closed
State-Changed-By: jdolecek@NetBSD.org
State-Changed-When: Sun, 24 Jan 2021 13:13:24 +0000
State-Changed-Why:
udata was actually changed to (void *)on 2019-10-04 for -current. It is
still in netbsd-9 branch. In either case reinterpret_cast() could
be used.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: gnats-precook-prs,v 1.4 2018/12/21 14:20:20 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.