From: Takashi Iwai Subject: Re: [PATCH alsa-lib 1/2] pcm_share: Fix compiler warnings -Wunused-result Date: Thu, 15 Nov 2018 12:08:18 +0100 Message-ID: References: <20181115071957.22753-1-kmarinushkin@birdec.tech> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id EB9FC2678F2 for ; Thu, 15 Nov 2018 12:08:19 +0100 (CET) In-Reply-To: <20181115071957.22753-1-kmarinushkin@birdec.tech> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Kirill Marinushkin Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org On Thu, 15 Nov 2018 08:19:56 +0100, Kirill Marinushkin wrote: > > Before this commit, compilation of `pcm_share` causes warnings "ignoring > return value" for several `read` and `write` operations: > > ~~~~ > pcm_share.c: In function '_snd_pcm_share_missing': > pcm_share.c:293:5: warning: ignoring return value of 'read', declared with > attribute warn_unused_result [-Wunused-result] > read(share->slave_socket, buf, 1); > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > <...> > ~~~~ > > However, ignoring return values in these use-cases is safe and optimal, > because `read` and `write` operations are executed upon descriptors, > created with `socketpair()` and `pipe()`. > > This commit fixes the warnings by introducing the return value with the > attribute `unused` (for details, see [1]). The macro, used in this commit, > is defined at `global.h`: > > ~~~~ > define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) > ~~~~ > > I explicitly checked the objdump: this commit doesn't change the machine > code, related to the modified C code lines. The execution performance is > not affected. > > [1] https://gcc.gnu.org/onlinedocs/gcc-8.2.0/gcc/Common-Variable-Attributes.html > > Signed-off-by: Kirill Marinushkin Which compiler version? I'm using gcc 8.2.1, and couldn't get any warnings like the above. thanks, Takashi