2727
2828#include "net.h"
2929
30+ /* Zephyr versions 4.2.0 and above return int, versions below 4.2.0 return void */
31+ #if (ZEPHYR_VERSION_CODE < ZEPHYR_VERSION (4 , 2 , 0 ))
32+ #define HTTP_CALLBACK_RETURN_VALUE
33+ #define HTTP_CALLBACK_RETURN_TYPE void
34+ #else
35+ #define HTTP_CALLBACK_RETURN_VALUE 0
36+ #define HTTP_CALLBACK_RETURN_TYPE int
37+ #endif
38+
3039/**
3140 * @brief HTTP User-Agent
3241 */
@@ -58,16 +67,18 @@ static mender_http_config_t http_config;
5867 * @param response HTTP response structure
5968 * @param final_call Indicate final call
6069 * @param user_data User data, used to retrieve request context data
70+ * @return HTTP_CALLBACK_RETURN_VALUE, 0 if Zephyr >= 4.2.0, void otherwise
6171 */
62- static void http_response_cb (struct http_response * response , enum http_final_call final_call , void * user_data );
72+ static HTTP_CALLBACK_RETURN_TYPE http_response_cb (struct http_response * response , enum http_final_call final_call , void * user_data );
6373
6474/**
6575 * @brief HTTP artifact response callback, invoked to handle data received
6676 * @param response HTTP response structure
6777 * @param final_call Indicate final call
6878 * @param user_data User data, used to retrieve request context data
79+ * @return HTTP_CALLBACK_RETURN_VALUE, 0 if Zephyr >= 4.2.0, void otherwise
6980 */
70- static void artifact_response_cb (struct http_response * response , enum http_final_call final_call , void * user_data );
81+ static HTTP_CALLBACK_RETURN_TYPE artifact_response_cb (struct http_response * response , enum http_final_call final_call , void * user_data );
7182
7283/**
7384 * @brief Convert mender HTTP method to Zephyr HTTP client method
@@ -352,7 +363,7 @@ mender_http_exit(void) {
352363 return MENDER_OK ;
353364}
354365
355- static void
366+ static HTTP_CALLBACK_RETURN_TYPE
356367http_response_cb (struct http_response * response , MENDER_ARG_UNUSED enum http_final_call final_call , void * user_data ) {
357368 assert (NULL != response );
358369 assert (NULL != user_data );
@@ -370,9 +381,10 @@ http_response_cb(struct http_response *response, MENDER_ARG_UNUSED enum http_fin
370381 mender_log_error ("An error occurred, stop reading data" );
371382 }
372383 }
384+ return HTTP_CALLBACK_RETURN_VALUE ;
373385}
374386
375- static void
387+ static HTTP_CALLBACK_RETURN_TYPE
376388artifact_response_cb (struct http_response * response , MENDER_ARG_UNUSED enum http_final_call final_call , void * user_data ) {
377389
378390 assert (NULL != response );
@@ -390,6 +402,7 @@ artifact_response_cb(struct http_response *response, MENDER_ARG_UNUSED enum http
390402 mender_log_error ("An error occurred, stop reading data" );
391403 }
392404 }
405+ return HTTP_CALLBACK_RETURN_VALUE ;
393406}
394407
395408static enum http_method
0 commit comments