From: Takashi Iwai Subject: Re: [PATCH 1/2] New Control Plugin - arcam-av Date: Sun, 04 Jan 2009 15:16:29 +0100 Message-ID: References: <200901032056.35982.linux@dadeos.co.uk> <20090103233558.GR32364@curie-int.orbis-terrarum.net> <200901041237.11381.linux@dadeos.co.uk> 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 mx2.suse.de (mx2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 46E221037F1 for ; Sun, 4 Jan 2009 15:16:30 +0100 (CET) In-Reply-To: <200901041237.11381.linux@dadeos.co.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Peter Stokes Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Sun, 4 Jan 2009 12:37:11 +0000, Peter Stokes wrote: > > --- alsa-plugins-1.0.18-orig/arcam-av/arcam_av.c 1970-01-01 01:00:00.000000000 > +0100 > +++ alsa-plugins-1.0.18/arcam-av/arcam_av.c 2009-01-02 22:30:55.000000000 > +0000 Looks like your embedded patches are broken due to line-breaks by MUA. Please fix it, or use attachments if it's difficult. > +int arcam_av_connect(const char* port) > +{ > + int fd = open(port, O_RDWR | O_NOCTTY); > + if (fd < 0) > + return -errno; > + > + struct termios portsettings; Put this into the beginning to follow the standard C. > +int arcam_av_send(int fd, arcam_av_cc_t command, unsigned char param1, > unsigned char param2) > +{ > + char buffer[7] = {'P', 'C', '_', command, param1, param2, 0x0D}; > + > + tcdrain(fd); > + ssize_t bytes = write(fd, buffer, 7); Ditto. > + if (bytes == 7) > + return 0; > + else if (bytes >= 0) > + return -1; No proper error code? > +static int arcam_av_receive(int fd, arcam_av_cc_t* command, unsigned char* > param1, unsigned char* param2) > +{ > + static int index = 0; > + static arcam_av_cc_t received_command; > + static unsigned char received_param1; > + static unsigned char received_param2; Are static variables safe to use here? That is, is the plugin designed to access exclusively with a proper protection? > + > + do { > + static char buffer[8]; Ditto. > + ssize_t bytes = read(fd, buffer, sizeof buffer - index); > + > + if (bytes <= 0) > + return -errno; > + > + char* cursor = buffer; Don't define a variable in the middle. Well, I'll review the rest after my vacation is over... thanks, Takashi