From owner-freebsd-standards@FreeBSD.ORG Mon Aug 6 05:50:08 2012 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44F041065678 for ; Mon, 6 Aug 2012 05:50:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BEB8F8FC0A for ; Mon, 6 Aug 2012 05:50:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q765o1n0058129 for ; Mon, 6 Aug 2012 05:50:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q765o1jh058128; Mon, 6 Aug 2012 05:50:01 GMT (envelope-from gnats) Resent-Date: Mon, 6 Aug 2012 05:50:01 GMT Resent-Message-Id: <201208060550.q765o1jh058128@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-standards@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, William Ahern Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 72AC91065670 for ; Mon, 6 Aug 2012 05:41:48 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 5D96F8FC0C for ; Mon, 6 Aug 2012 05:41:48 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q765flLv012686 for ; Mon, 6 Aug 2012 05:41:47 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q765flwf012685; Mon, 6 Aug 2012 05:41:47 GMT (envelope-from nobody) Message-Id: <201208060541.q765flwf012685@red.freebsd.org> Date: Mon, 6 Aug 2012 05:41:47 GMT From: William Ahern To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: standards/170403: wrong ntohs expression type tickling clang X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2012 05:50:08 -0000 >Number: 170403 >Category: standards >Synopsis: wrong ntohs expression type tickling clang >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Aug 06 05:50:01 UTC 2012 >Closed-Date: >Last-Modified: >Originator: William Ahern >Release: 9.0-RELEASE >Organization: >Environment: FreeBSD fbsd 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64 >Description: I reported this bug to Apple a couple of years ago. Maybe it was inherited from FreeBSD. The source of the problem is ntohs/htons optimization. ntohs expands to (__builtin_constant_p(_x) ? __bswap16_const((__uint16_t)(_x)) : __bswap16_var(_x)) in /usr/include/machine/endian.h. The problem is that the promoted type of that ternary expression is int. But ntohs and htons are defined to have a return type of uint16_t. Normally, this is a case of no harm no foul because basically every value gets promoted to int eventually, when used as an operand or argument. Nonetheless, the clang printf analyzer complains when using the %hu format specifier. GCC keeps silent, which is probably why this issue never came to anybody's attention. $ make CC=clang foo clang -O2 -pipe foo.c -o foo foo.c:8:12: warning: conversion specifies type 'unsigned short' but the argument has type 'int' [-Wformat] printf("%hu\n", ntohs(i)); ~~^ ~~~~~~~~ %d 1 warning generated. >How-To-Repeat: // make CC=clang foo #include #include int main(void) { uint16_t i = 1234; printf("%hu\n", ntohs(i)); return 0; } >Fix: Cast the result of the __bswap16 expression to __uint16_t, either in the __ntohs/__htons macros, or in the __bswap16 macro directly like with __bswap16_const. >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-standards@FreeBSD.ORG Mon Aug 6 11:07:22 2012 Return-Path: Delivered-To: freebsd-standards@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0EB9B1065677 for ; Mon, 6 Aug 2012 11:07:22 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id D043C8FC0A for ; Mon, 6 Aug 2012 11:07:21 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q76B7LaV021923 for ; Mon, 6 Aug 2012 11:07:21 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q76B7Lt9021921 for freebsd-standards@FreeBSD.org; Mon, 6 Aug 2012 11:07:21 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 6 Aug 2012 11:07:21 GMT Message-Id: <201208061107.q76B7Lt9021921@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-standards@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-standards@FreeBSD.org X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Aug 2012 11:07:22 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o stand/170403 standards wrong ntohs expression type tickling clang o stand/170346 standards Changes to support waitid() and related stuff o stand/169697 standards syslogd(8) is not BOM aware o stand/166349 standards Support the assignment-allocation character for fscanf o stand/165236 standards The NONE Wi-Fi regulatory restricts use of channels 12 o stand/164787 standards dirfd() function not available when _POSIX_C_SOURCE is o kern/164674 standards [patch] [libc] vfprintf/vfwprintf return error (EOF) o o stand/162434 standards getaddrinfo: addrinfo.ai_family is an address family, o stand/154842 standards invalid request authenticator in the second and subseq o stand/150093 standards C++ std::locale support is broken o stand/130067 standards Wrong numeric limits in system headers? o stand/124860 standards flockfile(3) doesn't work when the memory has been exh o stand/121921 standards [patch] Add leap second support to at(1), atrun(8) o stand/116477 standards rm(1): rm behaves unexpectedly when using -r and relat o bin/116413 standards incorrect getconf(1) handling of unsigned constants gi o stand/116081 standards make does not work with the directive sinclude p stand/107561 standards [libc] [patch] [request] Missing SUS function tcgetsid o stand/100017 standards [Patch] Add fuser(1) functionality to fstat(1) a stand/86484 standards [patch] mkfifo(1) uses wrong permissions o stand/82654 standards C99 long double math functions are missing o stand/81287 standards [patch] fingerd(8) might send a line not ending in CRL a stand/80293 standards sysconf() does not support well-defined unistd values o stand/79056 standards [feature request] [atch] regex(3) regression tests o stand/70813 standards [patch] ls(1) not Posix compliant o stand/66357 standards make POSIX conformance problem ('sh -e' & '+' command- s kern/64875 standards [libc] [patch] [request] add a system call: fdatasync( o stand/56476 standards [patch] cd9660 unicode support simple hack o stand/54410 standards one-true-awk not POSIX compliant (no extended REs) o stand/46119 standards Priority problems for SCHED_OTHER using pthreads o stand/44365 standards [headers] [patch] [request] introduce ulong and unchar a stand/41576 standards ln(1): replacing old dir-symlinks a docs/26003 standards getgroups(2) lists NGROUPS_MAX but not syslimits.h s stand/24590 standards timezone function not compatible witn Single Unix Spec o stand/21519 standards sys/dir.h should be deprecated some more s bin/14925 standards getsubopt isn't poisonous enough 35 problems total. From owner-freebsd-standards@FreeBSD.ORG Thu Aug 9 04:00:07 2012 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B8210106566B for ; Thu, 9 Aug 2012 04:00:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 76E898FC08 for ; Thu, 9 Aug 2012 04:00:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q79407b6086935 for ; Thu, 9 Aug 2012 04:00:07 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q79407gq086934; Thu, 9 Aug 2012 04:00:07 GMT (envelope-from gnats) Date: Thu, 9 Aug 2012 04:00:07 GMT Message-Id: <201208090400.q79407gq086934@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: David Xu Cc: Subject: Re: standards/170346: Changes to support waitid() and related stuff X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: David Xu List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Aug 2012 04:00:07 -0000 The following reply was made to PR standards/170346; it has been noted by GNATS. From: David Xu To: bug-followup@freebsd.org, jau@iki.fi Cc: Subject: Re: standards/170346: Changes to support waitid() and related stuff Date: Thu, 09 Aug 2012 11:50:22 +0800 Excellent work. I think idtype should be types.h. Also can you improve the patch according to Jilles Tjoelker's comments. I found google Chromium browser uses the waitid: http://code.google.com/p/chromium/source/search?q=waitid&origq=waitid&btnG=Search+Trunk -- David Xu