[opkg][opkg-0.5.0 PATCH] opkg_download_curl: relocate return code declaration

7 views
Skip to first unread message

Alex Stewart

unread,
Jul 14, 2021, 1:13:21 PM7/14/21
to opkg-...@googlegroups.com, alex.s...@ni.com
When libopkg is compiled with `--enable-curl` AND `--disable-ssl-curl`
options, the `int r` declaration in opkg_curl_init() becomes orphaned
from the code segments which actually use it (which are dropped via
DEFINEs). GCC throws an unused variable warning, as a result.

In modern C, there is no reason that variable declarations need to
happen at the top of the function block. So move the declaration into
the code segment that actually uses it, and within the relevant #DEFINE
block.

Signed-off-by: Alex Stewart <alex.s...@ni.com>
---
libopkg/opkg_download_curl.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libopkg/opkg_download_curl.c b/libopkg/opkg_download_curl.c
index a3249a06019fb04193a7915915c82b063ae4e62f..3017c281586f3b7c2a92531d901ca63f476387ea 100644
--- a/libopkg/opkg_download_curl.c
+++ b/libopkg/opkg_download_curl.c
@@ -374,8 +374,6 @@ void opkg_download_cleanup(void)

static CURL *opkg_curl_init(curl_progress_func cb, void *data)
{
- int r;
-
if (curl == NULL) {
curl = curl_easy_init();

@@ -384,6 +382,8 @@ static CURL *opkg_curl_init(curl_progress_func cb, void *data)
openssl_init();
#endif /* HAVE_OPENSSL */

+ int r;
+
if (opkg_config->ssl_engine) {
/* use crypto engine */
r = curl_easy_setopt(curl, CURLOPT_SSLENGINE,
--
2.32.0

Alex Stewart

unread,
Jul 15, 2021, 4:24:43 PM7/15/21
to opkg-...@googlegroups.com
Merged as commit: bfffedbbdc20bf08c3f28aa0c142426e66a23974

https://git.yoctoproject.org/cgit/cgit.cgi/opkg/commit/?id=bfffedbbdc20bf08c3f28aa0c142426e66a23974
Alex Stewart
Software Engineer - NI Real-Time OS
NI (National Instruments)

alex.s...@ni.com

Reply all
Reply to author
Forward
0 new messages