Commit 39fcefe
committed
libretro-common/samples/net: fix bit-rot in net_http_test
The sample was still calling the old single-argument form
net_http_new(const char *url), which was refactored a while back
into the two-stage connection API:
net_http_connection_new(url, method, data) -- build handle
net_http_connection_iterate(conn) -- drive to ready
net_http_connection_done(conn) -- check success
net_http_new(conn) -- transfer handle
net_http_update(http, &pos, &tot) -- drive xfer
net_http_data(http, &len, false) -- fetch body
net_http_delete(http)
net_http_connection_free(conn)
The sample compiled (CFLAGS is -Wall without -Werror in the
samples Makefile) but every CI build emitted two
"incompatible pointer type" warnings:
net_http_test.c:40:25: warning: passing argument 1 of
'net_http_new' from incompatible pointer type
Also fixed two secondary bit-rot issues in the same file:
- net_http_data returns uint8_t* now, not char*. The sample
assigned into a char* without a cast.
- %.9lu was used with size_t. Cast to unsigned long before
printf.
The canonical usage pattern is taken verbatim from
tasks/task_http.c (cb_http_conn_default plus
task_push_http_transfer). The behaviour from the sample's
original intent -- fetch a URL, print the first 256 bytes -- is
preserved and factored into a helper so the two example URLs
exercise the same code path.
Verified:
- CFLAGS += -Wall -Werror -pedantic -std=gnu99: clean compile
(0 warnings, 0 errors)
- CFLAGS += -Wall -Wextra -pedantic: clean compile
- Full libretro-common samples CI dry-run:
Built: 14 Ran: 13 Failed: 0
The net_http_new warnings are gone. Remaining warnings from
the dry-run are pre-existing and unrelated (compat_snprintf
empty translation unit, net_http_parse_test.c implicit
declaration, rzip.c fgets return value).
Regression test: NONE. http_test is a build-only sample -- it
makes live network requests to external hosts (wikipedia.org,
buildbot.libretro.com) and is not in the samples CI RUN_TARGETS
allowlist. The patch is verified at build time under -Werror,
which is strictly stricter than the samples Makefile's current
-Wall.1 parent ac95b67 commit 39fcefe
1 file changed
Lines changed: 54 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
32 | 44 | | |
33 | | - | |
34 | | - | |
35 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
36 | 49 | | |
37 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
38 | 54 | | |
| 55 | + | |
39 | 56 | | |
40 | | - | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
41 | 65 | | |
42 | | - | |
43 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
44 | 73 | | |
45 | | - | |
46 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
47 | 77 | | |
48 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
49 | 81 | | |
50 | | - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
51 | 91 | | |
52 | | - | |
53 | | - | |
| 92 | + | |
| 93 | + | |
54 | 94 | | |
55 | 95 | | |
56 | 96 | | |
0 commit comments