Skip to content

Commit 6958bcc

Browse files
authored
fix compiler warnings (#800)
* fix compiler warnings * add free
1 parent 8b86678 commit 6958bcc

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

contrib/win32/win32compat/fileio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ fileio_write_wrapper(struct w32_io* pio, const void* buf, size_t bytes_to_copy)
702702
int bytes_copied = -1;
703703
size_t chunk_size = 0;
704704

705-
for (int i = 0; i < bytes_to_copy; i += WRITE_BUFFER_SIZE, chunk_count++) {
705+
for (size_t i = 0; i < bytes_to_copy; i += WRITE_BUFFER_SIZE, chunk_count++) {
706706
chunk_buf = (BYTE*)buf + chunk_count * WRITE_BUFFER_SIZE;
707707
chunk_size = ((bytes_to_copy - i) >= WRITE_BUFFER_SIZE) ? WRITE_BUFFER_SIZE : (bytes_to_copy - i);
708708
bytes_written = fileio_write(pio, chunk_buf, chunk_size);

contrib/win32/win32compat/misc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@ readpassphrase(const char *prompt, char *outBuf, size_t outBufLen, int flags)
12621262
fatal("character conversion failed");
12631263

12641264
/* append to output buffer if the characters fit */
1265-
if (current_index + utf8_read >= outBufLen - 1) break;
1265+
if (current_index + utf8_read >= (int)outBufLen - 1) break;
12661266
memcpy(&outBuf[current_index], utf8_char, utf8_read);
12671267
current_index += utf8_read;
12681268

contrib/win32/win32compat/w32fd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,19 @@ fd_table_initialize()
8989
{
9090
struct w32_io *pio;
9191
HANDLE wh;
92-
char *stdio_mode_env;
92+
char *stdio_mode_env = NULL;
9393
int stdio_mode = NONSOCK_SYNC_FD;
94+
size_t len = 0;
9495

95-
stdio_mode_env = getenv("OPENSSH_STDIO_MODE");
96+
_dupenv_s(&stdio_mode_env, &len, "OPENSSH_STDIO_MODE");
9697
if (stdio_mode_env != NULL) {
9798
if (strcmp(stdio_mode_env, "sock") == 0)
9899
stdio_mode = SOCK_FD;
99100
else if (strcmp(stdio_mode_env, "nonsock") == 0)
100101
stdio_mode = NONSOCK_FD;
101102
else if (strcmp(stdio_mode_env, "nonsock_sync") == 0)
102103
stdio_mode = NONSOCK_SYNC_FD;
104+
free(stdio_mode_env);
103105
}
104106

105107
/* table entries representing std in, out and error*/

contrib/win32/win32compat/win32_dirent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ basename(char *path)
277277
while (endp > path && (*endp == '/' || *endp == '\\'))
278278
endp--;
279279

280-
int path_len = endp - path + 1;
280+
size_t path_len = endp - path + 1;
281281
if (strncpy_s(bname, PATH_MAX, path, path_len + 1)) {
282282
return NULL;
283283
}

0 commit comments

Comments
 (0)