Patchwork Binary access to files

login
register
about
Submitter Patrick Georgi
Date 2010-01-23 19:43:28
Message ID <4B5B5160.5090603@georgi-clan.de>
Download mbox | patch
Permalink /patch/834/
State Accepted
Headers show

Comments

Patrick Georgi - 2010-01-23 19:43:28
Hi,

attached patch opens files in "binary" mode for reading and writing.
That doesn't matter on unix, but on Windows (and maybe Mac OS) there
will be newline conversions that don't belong into binary images.

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>


Patrick
Stefan Reinauer - 2010-01-23 19:50:29
On 1/23/10 8:43 PM, Patrick Georgi wrote:
> Hi,
>
> attached patch opens files in "binary" mode for reading and writing.
> That doesn't matter on unix, but on Windows (and maybe Mac OS) there
> will be newline conversions that don't belong into binary images.
>
> Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
Patrick Georgi - 2010-01-25 22:57:44
Am 23.01.2010 20:50, schrieb Stefan Reinauer:
> On 1/23/10 8:43 PM, Patrick Georgi wrote:
>   
>> Hi,
>>
>> attached patch opens files in "binary" mode for reading and writing.
>> That doesn't matter on unix, but on Windows (and maybe Mac OS) there
>> will be newline conversions that don't belong into binary images.
>>
>> Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
>>     
> Acked-by: Stefan Reinauer <stepan@coresystems.de>
>   
Thanks, r882


Patrick

Patch

Index: flashrom.c

===================================================================
--- flashrom.c	(Revision 881)

+++ flashrom.c	(Arbeitskopie)

@@ -834,7 +834,7 @@ 

 		printf("Error: No filename specified.\n");
 		return 1;
 	}
-	if ((image = fopen(filename, "w")) == NULL) {
+	if ((image = fopen(filename, "wb")) == NULL) {
 		perror(filename);
 		exit(1);
 	}
@@ -1154,7 +1154,7 @@ 

 				fprintf(stderr, "Continuing anyway.\n");
 			}
 		}
-		if ((image = fopen(filename, "r")) == NULL) {
+		if ((image = fopen(filename, "rb")) == NULL) {
 			perror(filename);
 			programmer_shutdown();
 			exit(1);