Skip to content

Commit

Permalink
CI: build examples for additional code verification
Browse files Browse the repository at this point in the history
Some CIs already build them, let's do it on more of them.

Ignore -Wformat while using GCC on mingw to compile examples.
Improve size_t to long conversion in imap-append.c example.

Ref: curl#6079
Ref: curl#6082
Assisted-by: Jay Satiro

Follow up to curl#7690
Replaces curl#7591
Closes curl#7922
  • Loading branch information
mback2k committed Nov 8, 2021
1 parent a28464a commit 7b4c3ec
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 6 deletions.
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 @@ -34,6 +34,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
5 changes: 5 additions & 0 deletions docs/examples/anyauthput.c
Expand Up @@ -31,6 +31,11 @@

#include <curl/curl.h>

#if defined(__GNUC__) && defined(__MINGW32__)
/* GCC 10 on mingw has issues with this, disable */
#pragma GCC diagnostic ignored "-Wformat"
#endif

#ifdef WIN32
# include <io.h>
# define READ_3RD_ARG unsigned int
Expand Down
5 changes: 5 additions & 0 deletions docs/examples/chkspeed.c
Expand Up @@ -40,6 +40,11 @@

#include <curl/curl.h>

#if defined(__GNUC__) && defined(__MINGW32__)
/* GCC 10 on mingw has issues with this, disable */
#pragma GCC diagnostic ignored "-Wformat"
#endif

#define URL_BASE "http://speedtest.your.domain/"
#define URL_1M URL_BASE "file_1M.bin"
#define URL_2M URL_BASE "file_2M.bin"
Expand Down
5 changes: 5 additions & 0 deletions docs/examples/fileupload.c
Expand Up @@ -28,6 +28,11 @@
#include <sys/stat.h>
#include <fcntl.h>

#if defined(__GNUC__) && defined(__MINGW32__)
/* GCC 10 on mingw has issues with this, disable */
#pragma GCC diagnostic ignored "-Wformat"
#endif

int main(void)
{
CURL *curl;
Expand Down
5 changes: 5 additions & 0 deletions docs/examples/ftpupload.c
Expand Up @@ -33,6 +33,11 @@
#include <unistd.h>
#endif

#if defined(__GNUC__) && defined(__MINGW32__)
/* GCC 10 on mingw has issues with this, disable */
#pragma GCC diagnostic ignored "-Wformat"
#endif

/* <DESC>
* Performs an FTP upload and renames the file just after a successful
* transfer.
Expand Down
5 changes: 5 additions & 0 deletions docs/examples/httpput.c
Expand Up @@ -28,6 +28,11 @@
#include <sys/stat.h>
#include <curl/curl.h>

#if defined(__GNUC__) && defined(__MINGW32__)
/* GCC 10 on mingw has issues with this, disable */
#pragma GCC diagnostic ignored "-Wformat"
#endif

/*
* This example shows a HTTP PUT operation. PUTs a file given as a command
* line argument to the URL also given on the command line.
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
5 changes: 5 additions & 0 deletions docs/examples/progressfunc.c
Expand Up @@ -27,6 +27,11 @@
#include <stdio.h>
#include <curl/curl.h>

#if defined(__GNUC__) && defined(__MINGW32__)
/* GCC 10 on mingw has issues with this, disable */
#pragma GCC diagnostic ignored "-Wformat"
#endif

#if LIBCURL_VERSION_NUM >= 0x073d00
/* In libcurl 7.61.0, support was added for extracting the time in plain
microseconds. Older libcurl versions are stuck in using 'double' for this
Expand Down
5 changes: 5 additions & 0 deletions docs/examples/sendrecv.c
Expand Up @@ -28,6 +28,11 @@
#include <string.h>
#include <curl/curl.h>

#if defined(__GNUC__) && defined(__MINGW32__)
/* GCC 10 on mingw has issues with this, disable */
#pragma GCC diagnostic ignored "-Wformat"
#endif

/* Auxiliary function that waits on the socket. */
static int wait_on_socket(curl_socket_t sockfd, int for_recv, long timeout_ms)
{
Expand Down
5 changes: 5 additions & 0 deletions docs/examples/sftpuploadresume.c
Expand Up @@ -28,6 +28,11 @@
#include <stdio.h>
#include <curl/curl.h>

#if defined(__GNUC__) && defined(__MINGW32__)
/* GCC 10 on mingw has issues with this, disable */
#pragma GCC diagnostic ignored "-Wformat"
#endif

/* read data to upload */
static size_t readfunc(char *ptr, size_t size, size_t nmemb, void *stream)
{
Expand Down

0 comments on commit 7b4c3ec

Please sign in to comment.