From patchwork Sun Dec 9 09:26:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Garrett Cooper X-Patchwork-Id: 1853551 X-Patchwork-Delegate: hal@mellanox.com Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A8A5B3FCF2 for ; Sun, 9 Dec 2012 09:26:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030386Ab2LIJ0x (ORCPT ); Sun, 9 Dec 2012 04:26:53 -0500 Received: from mail-pb0-f46.google.com ([209.85.160.46]:62859 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030308Ab2LIJ0t (ORCPT ); Sun, 9 Dec 2012 04:26:49 -0500 Received: by mail-pb0-f46.google.com with SMTP id wy7so1252856pbc.19 for ; Sun, 09 Dec 2012 01:26:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:user-agent:mime-version :content-type:content-id; bh=6Qhxpeg81EgPiNizI89oQ8ReTSbJrfKCIdP2Kxa0H3M=; b=FQILrplQ44010fwB08w1JhhWs02ilx6DuUU59fCZlcS3zr1Qk2rg06+tHw0MHK29ms v/kBMvFwr/eIY/mdm2MlxSm6LCu/E4DQdrqSalN/T6esN3FehNxhXTwJ1AWFS39Pfy5X bKvVRLTNyIgwYvaFLNmF1VmYfxMNpETMcDcnzMEpMOJk7vwxCs893+Edjf5YGZiX1I/3 FT5UTH0hnjLLVKaZ3xp0bQSc7ktd7Z3LNxM5YJ1PYCOJyzC2ev8AkjdExpgp9ql0xJKj l0OtYHXtgHXToAj36FvMfsShyNRLX1m/Zkv3ygzN3kaBC2upTmXM2OPspQlfzytzJjis OHhA== Received: by 10.68.137.167 with SMTP id qj7mr29139090pbb.148.1355045208606; Sun, 09 Dec 2012 01:26:48 -0800 (PST) Received: from c-24-19-191-56.hsd1.wa.comcast.net (c-24-19-191-56.hsd1.wa.comcast.net. [24.19.191.56]) by mx.google.com with ESMTPS id uk9sm9812031pbc.63.2012.12.09.01.26.47 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 09 Dec 2012 01:26:47 -0800 (PST) Date: Sun, 9 Dec 2012 01:26:42 -0800 (PST) From: Garrett Cooper To: linux-rdma@vger.kernel.org Subject: [PATCH] [RFC] osm_log printing incorrectly assumes that pthread_t is not opaque type Message-ID: User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-ID: Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Hi, When porting a newer version of OFED to FreeBSD and running the compile against clang with all of the warnings enabled, I ran into build failures because osm_log, etc assumes that pthread_t is an integral type (which is valid on Linux, but not necessarily correct on other platforms). The fix I implemented was attached, but that doesn't necessarily seem correct either, so I was wondering what was trying to be gained by printing out the thread ID (especially because syslog(9) isn't necessarily an asynch safe syscall [1]). Thanks, -Garrett 1. http://linux.die.net/man/7/signal From 55c3bafa1d866dc045e16fbf792dc64d03d25431 Mon Sep 17 00:00:00 2001 From: Garrett Cooper Date: Thu, 6 Dec 2012 21:41:17 -0800 Subject: [PATCH 2/2] Use %p when printing out pthread_t in the logging fns on FreeBSD A [slightly] more portable way to do this would be to use pthread_set(_)?name_np, but even that is not super well-defined across BSD versions, Linux, and OSX. See http://stackoverflow.com/questions/2369738/can-i-set-the-name-of-a-thread-in-pthreads-linux for more details. --- contrib/ofed/management/opensm/opensm/osm_log.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/ofed/management/opensm/opensm/osm_log.c b/contrib/ofed/management/opensm/opensm/osm_log.c index deadc57..f4ef394 100644 --- a/contrib/ofed/management/opensm/opensm/osm_log.c +++ b/contrib/ofed/management/opensm/opensm/osm_log.c @@ -189,7 +189,11 @@ _retry: _retry: ret = fprintf(p_log->out_port, +#if defined(__FreeBSD__) + "%s %02d %02d:%02d:%02d %06d [%p] 0x%02x -> %s", +#else "%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s", +#endif (result.tm_mon < 12 ? month_str[result.tm_mon] : "???"), result.tm_mday, result.tm_hour, result.tm_min, @@ -302,7 +306,12 @@ _retry: _retry: ret = fprintf(p_log->out_port, +#if defined(__FreeBSD__) + "%s %02d %02d:%02d:%02d %06d [%p] 0x%02x -> %s", +#else "%s %02d %02d:%02d:%02d %06d [%04X] 0x%02x -> %s", + +#endif (result.tm_mon < 12 ? month_str[result.tm_mon] : "???"), result.tm_mday, result.tm_hour, result.tm_min,