]> git.wh0rd.org Git - patches.git/blob - ldrviewer-retry.patch
initial import
[patches.git] / ldrviewer-retry.patch
1 ? ldrs
2 ? ldrviewer
3 Index: headers.h
4 ===================================================================
5 RCS file: /cvsroot/gcc3/ldrviewer/headers.h,v
6 retrieving revision 1.2
7 diff -u -p -r1.2 headers.h
8 --- headers.h   22 Sep 2006 01:44:59 -0000      1.2
9 +++ headers.h   17 Oct 2006 20:54:10 -0000
10 @@ -21,6 +21,7 @@
11  #include <stdlib.h>
12  #include <string.h>
13  #include <strings.h>
14 +#include <errno.h>
15  #include <assert.h>
16  #include <stdint.h>
17  #include <sys/types.h>
18 Index: helpers.c
19 ===================================================================
20 RCS file: /cvsroot/gcc3/ldrviewer/helpers.c,v
21 retrieving revision 1.2
22 diff -u -p -r1.2 helpers.c
23 --- helpers.c   22 Sep 2006 01:44:59 -0000      1.2
24 +++ helpers.c   17 Oct 2006 20:54:10 -0000
25 @@ -40,3 +40,24 @@ int parse_bool(const char *boo)
26                 return 0;
27         err("Invalid boolean: '%s'", boo);
28  }
29 +
30 +ssize_t read_retry(int fd, void *buf, size_t count)
31 +{
32 +       ssize_t ret = 0, temp_ret;
33 +       while (count > 0) {
34 +               temp_ret = read(fd, buf, count);
35 +               if (temp_ret > 0) {
36 +                       ret += temp_ret;
37 +                       buf += temp_ret;
38 +                       count -= temp_ret;
39 +               } else if (temp_ret == 0) {
40 +                       break;
41 +               } else {
42 +                       if (errno == EINTR)
43 +                               continue;
44 +                       ret = -1;
45 +                       break;
46 +               }
47 +       }
48 +       return ret;
49 +}
50 Index: helpers.h
51 ===================================================================
52 RCS file: /cvsroot/gcc3/ldrviewer/helpers.h,v
53 retrieving revision 1.2
54 diff -u -p -r1.2 helpers.h
55 --- helpers.h   22 Sep 2006 01:44:59 -0000      1.2
56 +++ helpers.h   17 Oct 2006 20:54:10 -0000
57 @@ -41,5 +41,6 @@ extern const char *argv0;
58  void *xmalloc(size_t);
59  void *xrealloc(void *, size_t);
60  int parse_bool(const char *);
61 +ssize_t read_retry(int, void *, size_t);
62  
63  #endif
64 Index: ldr.c
65 ===================================================================
66 RCS file: /cvsroot/gcc3/ldrviewer/ldr.c,v
67 retrieving revision 1.2
68 diff -u -p -r1.2 ldr.c
69 --- ldr.c       22 Sep 2006 01:44:59 -0000      1.2
70 +++ ldr.c       17 Oct 2006 20:54:10 -0000
71 @@ -379,7 +379,7 @@ canned_failure:
72         printf("OK!\n");
73  
74         printf("Trying to read autobaud ... ");
75 -       ret = read(fd, autobaud, 4);
76 +       ret = read_retry(fd, autobaud, 4);
77         if (ret != 4)
78                 goto canned_failure;
79         printf("OK!\n");