Skip to content

Commit

Permalink
Remove compile warnings on openBSD
Browse files Browse the repository at this point in the history
  • Loading branch information
trondn authored and dustin committed Dec 31, 2009
1 parent fcc0930 commit cb10b04
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions testapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ static pid_t start_server(in_port_t *port_out, bool daemon, int timeout) {
overwrite each other
*/
char coreadm[128];
sprintf(coreadm, "coreadm -p core.%%f.%%p %lu", (unsigned long)getpid());
snprintf(coreadm, sizeof(coreadm),
"coreadm -p core.%%f.%%p %lu", (unsigned long)getpid());
system(coreadm);
#endif

Expand Down Expand Up @@ -551,10 +552,11 @@ static enum test_return test_issue_102(void) {
close(sock);
sock = connect_server("127.0.0.1", port, false);

sprintf(buffer, "gets ");
snprintf(buffer, sizeof(buffer), "gets ");
size_t offset = 5;
while (offset < 4000) {
offset += sprintf(buffer + offset, "%010u ", (unsigned int)offset);
offset += snprintf(buffer + offset, sizeof(buffer) - offset,
"%010u ", (unsigned int)offset);
}

send_ascii_command(buffer);
Expand All @@ -571,9 +573,10 @@ static enum test_return test_issue_102(void) {
read_ascii_response(rsp, sizeof(rsp));
assert(strncmp(rsp, "END", strlen("END")) == 0);


memset(buffer, ' ', 101);
strcat(buffer + 101, "gets foo");
memset(buffer, ' ', sizeof(buffer));
int len = snprintf(buffer + 101, sizeof(buffer) - 101, "gets foo");
buffer[101 + len] = ' ';
buffer[sizeof(buffer) - 1] = '\0';
send_ascii_command(buffer);
/* verify that the server closed the connection */
assert(read(sock, buffer, sizeof(buffer)) == 0);
Expand Down

0 comments on commit cb10b04

Please sign in to comment.