We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0197f61 commit 0072307Copy full SHA for 0072307
virtualsmartcard/src/vpcd/vpcd.c
@@ -64,21 +64,23 @@ static SOCKET connectsock(const char *hostname, unsigned short port);
64
65
ssize_t sendall(SOCKET sock, const void *buffer, size_t size)
66
{
67
- size_t sent;
+ size_t sent = 0;
68
ssize_t r;
69
70
/* FIXME we should actually check the length instead of simply casting from
71
* size_t to ssize_t (or int), which have both the same width! */
72
- for (sent = 0; sent < size; sent += r) {
+ while (sent < size) {
73
r = send(sock, (void *) (((unsigned char *) buffer)+sent),
74
#ifdef _WIN32
75
(int)
76
#endif
77
(size-sent), MSG_NOSIGNAL);
78
79
- if (r < 0)
80
- return r;
81
- }
+ if (r < 0)
+ return r;
+
82
+ sent += r;
83
+ }
84
85
return (ssize_t) sent;
86
}
0 commit comments