From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xmlya-0004RU-KE for qemu-devel@nongnu.org; Fri, 07 Nov 2014 11:01:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XmlyS-0002Kn-G5 for qemu-devel@nongnu.org; Fri, 07 Nov 2014 11:01:28 -0500 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:48852 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XmlyS-0002Kh-Ao for qemu-devel@nongnu.org; Fri, 07 Nov 2014 11:01:20 -0500 References: <20141107103123.6136.18545.stgit@PASHA-ISP> <20141107103155.6136.52380.stgit@PASHA-ISP> From: Alex =?utf-8?Q?Benn=C3=A9e?= In-reply-to: <20141107103155.6136.52380.stgit@PASHA-ISP> Date: Fri, 07 Nov 2014 16:01:19 +0000 Message-ID: <87a94357ao.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [RFC PATCH v4 05/25] replay: internal functions for replay log List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Pavel Dovgalyuk Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, qemu-devel@nongnu.org, maria.klimushenkova@ispras.ru, pbonzini@redhat.com, batuzovk@ispras.ru, afaerber@suse.de, fred.konrad@greensocs.com Pavel Dovgalyuk writes: > This patch adds functions to perform read and write operations > with replay log. > > Signed-off-by: Pavel Dovgalyuk > + > +/* File for replay writing */ > +FILE *replay_file; > + > +void replay_put_byte(unsigned char byte) > +{ > + if (replay_file) { > + fwrite(&byte, sizeof(byte), 1, replay_file); > + } > +} > + > +void replay_put_event(unsigned char event) > +{ > + replay_put_byte(event); > +} > + > + > +void replay_put_dword(unsigned int dword) > +{ > + if (replay_file) { > + fwrite(&dword, sizeof(dword), 1, replay_file); > + } > +} Given you use the unambiguous types bellow shouldn't you use uint8_t and uint32_t here to be safe? > + > +unsigned char replay_get_byte(void) > +{ > + unsigned char byte; > + if (replay_file) { > + fread(&byte, sizeof(byte), 1, replay_file); > + } > + return byte; > +} > + > +uint16_t replay_get_word(void) > +{ > + uint16_t word; > + if (replay_file) { > + fread(&word, sizeof(word), 1, replay_file); > + } > + > + return word; > +} > + > +unsigned int replay_get_dword(void) > +{ > + unsigned int dword; > + if (replay_file) { > + fread(&dword, sizeof(dword), 1, replay_file); > + } > + > + return dword; > +} Ditto for the fetchers -- Alex Bennée