From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CD48C43331 for ; Tue, 12 Nov 2019 20:26:59 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7580720674 for ; Tue, 12 Nov 2019 20:26:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="oW2lHIMC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7580720674 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 2CC8E74C; Tue, 12 Nov 2019 21:26:06 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 2CC8E74C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1573590416; bh=NneRlA18f0DW6PcsoFfIu7b67X27QRTZ+Y3+9U5XKdU=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=oW2lHIMCQrpB1YRxAWeQLgeHAzceFbMLYWhmx1aG+mPQ+NujBohwUWShC9tlyBlgZ 9Wf79ol4t2/BOTQO7AmGCptiFiKv/zWZZrCzicKLmN5JR17e7uffDYS7wAbfyN9BpE HNWTKRP3lrm04DyXk1eSnAnZQeUmhrNx6FpVtYoM= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 96A96F8049C; Tue, 12 Nov 2019 21:26:05 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id B9A90F804CF; Tue, 12 Nov 2019 21:26:04 +0100 (CET) Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2F4E7F802E0 for ; Tue, 12 Nov 2019 21:26:01 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2F4E7F802E0 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 161CFACEC; Tue, 12 Nov 2019 20:26:01 +0000 (UTC) Date: Tue, 12 Nov 2019 21:26:00 +0100 Message-ID: From: Takashi Iwai To: Arnd Bergmann In-Reply-To: References: <20191112151642.680072-1-arnd@arndb.de> <20191112151642.680072-6-arnd@arndb.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Cc: ALSA Development Mailing List , Baolin Wang , y2038 Mailman List , "linux-kernel@vger.kernel.org" , Takashi Iwai , Mark Brown , Baolin Wang Subject: Re: [alsa-devel] [PATCH v6 5/8] ALSA: Avoid using timespec for struct snd_rawmidi_status X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Tue, 12 Nov 2019 21:04:10 +0100, Arnd Bergmann wrote: > > On Tue, Nov 12, 2019 at 5:38 PM Takashi Iwai wrote: > > On Tue, 12 Nov 2019 16:16:39 +0100, Arnd Bergmann wrote: > > > +#ifndef __KERNEL__ > > > struct snd_rawmidi_status { > > > int stream; > > > + unsigned char pad1[sizeof(time_t) - sizeof(int)]; > > > struct timespec tstamp; /* Timestamp */ > > > size_t avail; /* available bytes */ > > > size_t xruns; /* count of overruns since last status (in bytes) */ > > > unsigned char reserved[16]; /* reserved for future use */ > > > }; > > > > Can we use union instead of padding? Something like: > > > > struct snd_rawmidi_status { > > union { > > int stream; > > time_t stream_alignment; > > }; > > struct timespec tstamp; /* Timestamp */ > > .... > > I think this would work most of the time, though I don't feel this is more > readable than the other version. > > More importantly, it requires compiling user applications with GNU extensions > (--std=gnu89 or higher) or C11, but not C99, so this could be a problem > for some applications. OK, fair enough. > If you feel there is a problem with the padding syntax, how about enclosing > it in a typedef like: > > typedef struct { char pad[sizeof(time_t) - sizeof(int)]; } __time_pad; > > This typedef could be used in several structures from the other patches > as well. Yes, that improves the readability. thanks, Takashi _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 647E9C43331 for ; Tue, 12 Nov 2019 20:26:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27BF521872 for ; Tue, 12 Nov 2019 20:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726988AbfKLU0D (ORCPT ); Tue, 12 Nov 2019 15:26:03 -0500 Received: from mx2.suse.de ([195.135.220.15]:38380 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726376AbfKLU0C (ORCPT ); Tue, 12 Nov 2019 15:26:02 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 161CFACEC; Tue, 12 Nov 2019 20:26:01 +0000 (UTC) Date: Tue, 12 Nov 2019 21:26:00 +0100 Message-ID: From: Takashi Iwai To: Arnd Bergmann Cc: ALSA Development Mailing List , Takashi Iwai , Baolin Wang , y2038 Mailman List , "linux-kernel@vger.kernel.org" , Mark Brown , Baolin Wang Subject: Re: [alsa-devel] [PATCH v6 5/8] ALSA: Avoid using timespec for struct snd_rawmidi_status In-Reply-To: References: <20191112151642.680072-1-arnd@arndb.de> <20191112151642.680072-6-arnd@arndb.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Nov 2019 21:04:10 +0100, Arnd Bergmann wrote: > > On Tue, Nov 12, 2019 at 5:38 PM Takashi Iwai wrote: > > On Tue, 12 Nov 2019 16:16:39 +0100, Arnd Bergmann wrote: > > > +#ifndef __KERNEL__ > > > struct snd_rawmidi_status { > > > int stream; > > > + unsigned char pad1[sizeof(time_t) - sizeof(int)]; > > > struct timespec tstamp; /* Timestamp */ > > > size_t avail; /* available bytes */ > > > size_t xruns; /* count of overruns since last status (in bytes) */ > > > unsigned char reserved[16]; /* reserved for future use */ > > > }; > > > > Can we use union instead of padding? Something like: > > > > struct snd_rawmidi_status { > > union { > > int stream; > > time_t stream_alignment; > > }; > > struct timespec tstamp; /* Timestamp */ > > .... > > I think this would work most of the time, though I don't feel this is more > readable than the other version. > > More importantly, it requires compiling user applications with GNU extensions > (--std=gnu89 or higher) or C11, but not C99, so this could be a problem > for some applications. OK, fair enough. > If you feel there is a problem with the padding syntax, how about enclosing > it in a typedef like: > > typedef struct { char pad[sizeof(time_t) - sizeof(int)]; } __time_pad; > > This typedef could be used in several structures from the other patches > as well. Yes, that improves the readability. thanks, Takashi