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