Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: build examples for additional code verification #7922

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .azure-pipelines.yml
Expand Up @@ -83,7 +83,7 @@ stages:
- script: ./buildconf && ./configure --enable-warnings --enable-werror $(configure)
displayName: 'configure $(name)'

- script: make V=1 && cd tests && make V=1
- script: make V=1 && make V=1 examples && cd tests && make V=1
displayName: 'compile'
env:
MAKEFLAGS: "-j 2"
Expand Down Expand Up @@ -191,7 +191,7 @@ stages:
- script: $(container_cmd) -l -c "cd $(echo '%cd%') && ./buildconf && ./configure $(configure)"
displayName: 'configure $(name)'

- script: $(container_cmd) -l -c "cd $(echo '%cd%') && make V=1 && cd tests && make V=1"
- script: $(container_cmd) -l -c "cd $(echo '%cd%') && make V=1 && make V=1 examples && cd tests && make V=1"
displayName: 'compile'
env:
MAKEFLAGS: "-j 2"
Expand Down
1 change: 1 addition & 0 deletions .circleci/config.yml
Expand Up @@ -36,6 +36,7 @@ commands:
build:
steps:
- run: make V=1
- run: make V=1 examples

test:
steps:
Expand Down
4 changes: 2 additions & 2 deletions .cirrus.yml
Expand Up @@ -57,7 +57,7 @@ freebsd_task:
# esac
- ./configure --prefix="${HOME}"/install --enable-debug --with-openssl --with-libssh2 --with-brotli --with-gssapi --with-libidn2 --enable-manual --enable-ldap --enable-ldaps --with-librtmp --with-libpsl --with-nghttp2 || { tail -300 config.log; false; }
compile_script:
- make V=1 && cd tests && make V=1
- make V=1 && make V=1 examples && cd tests && make V=1
test_script:
# blackhole?
- sysctl net.inet.tcp.blackhole
Expand Down Expand Up @@ -122,7 +122,7 @@ windows_task:
configure_script: |
%container_cmd% -l -c "cd $(echo '%cd%') && ./buildconf && ./configure %configure%"
compile_script: |
%container_cmd% -l -c "cd $(echo '%cd%') && make V=1 && cd tests && make V=1"
%container_cmd% -l -c "cd $(echo '%cd%') && make V=1 && make V=1 examples && cd tests && make V=1"
install_script: |
%container_cmd% -l -c "cd $(echo '%cd%') && make V=1 install && PATH=/usr/bin:/bin find . -type f -path '*/.libs/*.exe' -print -execdir mv -t .. {} \;"
test_script: |
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/anyauthput.c
Expand Up @@ -81,17 +81,17 @@ static curlioerr my_ioctl(CURL *handle, curliocmd cmd, void *userp)
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
ssize_t retcode;
curl_off_t nread;
unsigned long nread;

int *fdp = (int *)stream;
int fd = *fdp;

retcode = read(fd, ptr, (READ_3RD_ARG)(size * nmemb));

nread = (curl_off_t)retcode;

fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
" bytes from file\n", nread);
if(retcode > 0) {
nread = (unsigned long)retcode;
fprintf(stderr, "*** We read %lu bytes from file\n", nread);
}

return retcode;
}
Expand Down
18 changes: 9 additions & 9 deletions docs/examples/chkspeed.c
Expand Up @@ -170,32 +170,32 @@ int main(int argc, char *argv[])
/* check for bytes downloaded */
res = curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD_T, &val);
if((CURLE_OK == res) && (val>0))
printf("Data downloaded: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", val);
printf("Data downloaded: %lu bytes.\n", (unsigned long)val);

/* check for total download time */
res = curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME_T, &val);
if((CURLE_OK == res) && (val>0))
printf("Total download time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n",
(val / 1000000), (long)(val % 1000000));
printf("Total download time: %lu.%06lu sec.\n",
(unsigned long)(val / 1000000), (unsigned long)(val % 1000000));

/* check for average download speed */
res = curl_easy_getinfo(curl_handle, CURLINFO_SPEED_DOWNLOAD_T, &val);
if((CURLE_OK == res) && (val>0))
printf("Average download speed: %" CURL_FORMAT_CURL_OFF_T
" kbyte/sec.\n", val / 1024);
printf("Average download speed: %lu kbyte/sec.\n",
(unsigned long)(val / 1024));

if(prtall) {
/* check for name resolution time */
res = curl_easy_getinfo(curl_handle, CURLINFO_NAMELOOKUP_TIME_T, &val);
if((CURLE_OK == res) && (val>0))
printf("Name lookup time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n",
(val / 1000000), (long)(val % 1000000));
printf("Name lookup time: %lu.%06lu sec.\n",
(unsigned long)(val / 1000000), (unsigned long)(val % 1000000));

/* check for connect time */
res = curl_easy_getinfo(curl_handle, CURLINFO_CONNECT_TIME_T, &val);
if((CURLE_OK == res) && (val>0))
printf("Connect time: %" CURL_FORMAT_CURL_OFF_T ".%06ld sec.\n",
(val / 1000000), (long)(val % 1000000));
printf("Connect time: %lu.%06lu sec.\n",
(unsigned long)(val / 1000000), (unsigned long)(val % 1000000));
}
}
else {
Expand Down
10 changes: 4 additions & 6 deletions docs/examples/fileupload.c
Expand Up @@ -68,18 +68,16 @@ int main(void)
if(res != CURLE_OK) {
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));

}
else {
/* now extract transfer info */
curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD_T, &speed_upload);
curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &total_time);

fprintf(stderr, "Speed: %" CURL_FORMAT_CURL_OFF_T " bytes/sec during %"
CURL_FORMAT_CURL_OFF_T ".%06ld seconds\n",
speed_upload,
(total_time / 1000000), (long)(total_time % 1000000));

fprintf(stderr, "Speed: %lu bytes/sec during %lu.%06lu seconds\n",
(unsigned long)speed_upload,
(unsigned long)(total_time / 1000000),
(unsigned long)(total_time % 1000000));
}
/* always cleanup */
curl_easy_cleanup(curl);
Expand Down
15 changes: 8 additions & 7 deletions docs/examples/ftpupload.c
Expand Up @@ -50,16 +50,17 @@
variable's memory when passed in to it from an app like this. */
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
curl_off_t nread;
unsigned long nread;
/* in real-world cases, this would probably get this data differently
as this fread() stuff is exactly what the library already would do
by default internally */
size_t retcode = fread(ptr, size, nmemb, stream);

nread = (curl_off_t)retcode;
if(retcode > 0) {
nread = (unsigned long)retcode;
fprintf(stderr, "*** We read %lu bytes from file\n", nread);
}

fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
" bytes from file\n", nread);
return retcode;
}

Expand All @@ -69,7 +70,7 @@ int main(void)
CURLcode res;
FILE *hd_src;
struct stat file_info;
curl_off_t fsize;
unsigned long fsize;

struct curl_slist *headerlist = NULL;
static const char buf_1 [] = "RNFR " UPLOAD_FILE_AS;
Expand All @@ -80,9 +81,9 @@ int main(void)
printf("Couldn't open '%s': %s\n", LOCAL_FILE, strerror(errno));
return 1;
}
fsize = (curl_off_t)file_info.st_size;
fsize = (unsigned long)file_info.st_size;

printf("Local file size: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", fsize);
printf("Local file size: %lu bytes.\n", fsize);

/* get a FILE * of the same file */
hd_src = fopen(LOCAL_FILE, "rb");
Expand Down
10 changes: 5 additions & 5 deletions docs/examples/httpput.c
Expand Up @@ -41,17 +41,17 @@
static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *stream)
{
size_t retcode;
curl_off_t nread;
unsigned long nread;

/* in real-world cases, this would probably get this data differently
as this fread() stuff is exactly what the library already would do
by default internally */
retcode = fread(ptr, size, nmemb, stream);

nread = (curl_off_t)retcode;

fprintf(stderr, "*** We read %" CURL_FORMAT_CURL_OFF_T
" bytes from file\n", nread);
if(retcode > 0) {
nread = (unsigned long)retcode;
fprintf(stderr, "*** We read %lu bytes from file\n", nread);
}

return retcode;
}
Expand Down
7 changes: 5 additions & 2 deletions docs/examples/imap-append.c
Expand Up @@ -89,7 +89,8 @@ int main(void)

curl = curl_easy_init();
if(curl) {
long infilesize;
size_t filesize;
long infilesize = LONG_MAX;
struct upload_status upload_ctx = { 0 };

/* Set username and password */
Expand All @@ -108,7 +109,9 @@ int main(void)
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);

infilesize = strlen(payload_text);
filesize = strlen(payload_text);
if(filesize <= LONG_MAX)
infilesize = (long)filesize;
curl_easy_setopt(curl, CURLOPT_INFILESIZE, infilesize);

/* Perform the append */
Expand Down
12 changes: 6 additions & 6 deletions docs/examples/progressfunc.c
Expand Up @@ -51,14 +51,14 @@ static int xferinfo(void *p,
be used */
if((curtime - myp->lastruntime) >= MINIMAL_PROGRESS_FUNCTIONALITY_INTERVAL) {
myp->lastruntime = curtime;
fprintf(stderr, "TOTAL TIME: %" CURL_FORMAT_CURL_OFF_T ".%06ld\r\n",
(curtime / 1000000), (long)(curtime % 1000000));
fprintf(stderr, "TOTAL TIME: %lu.%06lu\r\n",
(unsigned long)(curtime / 1000000),
(unsigned long)(curtime % 1000000));
}

fprintf(stderr, "UP: %" CURL_FORMAT_CURL_OFF_T " of %" CURL_FORMAT_CURL_OFF_T
" DOWN: %" CURL_FORMAT_CURL_OFF_T " of %" CURL_FORMAT_CURL_OFF_T
"\r\n",
ulnow, ultotal, dlnow, dltotal);
fprintf(stderr, "UP: %lu of %lu DOWN: %lu of %lu\r\n",
(unsigned long)ulnow, (unsigned long)ultotal,
(unsigned long)dlnow, (unsigned long)dltotal);

if(dlnow > STOP_DOWNLOAD_AFTER_THIS_MANY_BYTES)
return 1;
Expand Down
6 changes: 2 additions & 4 deletions docs/examples/sendrecv.c
Expand Up @@ -120,8 +120,7 @@ int main(void)
return 1;
}

printf("Sent %" CURL_FORMAT_CURL_OFF_T " bytes.\n",
(curl_off_t)nsent);
printf("Sent %lu bytes.\n", (unsigned long)nsent);

} while(nsent_total < request_len);

Expand Down Expand Up @@ -151,8 +150,7 @@ int main(void)
break;
}

printf("Received %" CURL_FORMAT_CURL_OFF_T " bytes.\n",
(curl_off_t)nread);
printf("Received %lu bytes.\n", (unsigned long)nread);
}

/* always cleanup */
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/sftpuploadresume.c
Expand Up @@ -66,7 +66,7 @@ static curl_off_t sftpGetRemoteFileSize(const char *i_remoteFile)
&remoteFileSizeByte);
if(result)
return -1;
printf("filesize: %" CURL_FORMAT_CURL_OFF_T "\n", remoteFileSizeByte);
printf("filesize: %lu\n", (unsigned long)remoteFileSizeByte);
}
curl_easy_cleanup(curlHandlePtr);

Expand Down