mirror of
https://github.com/moparisthebest/curl
synced 2025-01-10 21:48:10 -05:00
misc: fix "warning: empty expression statement has no effect"
Turned several macros into do-while(0) style to allow their use to work find with semicolon. Bug:08e8455ddd (commitcomment-45433279)
Follow-up to08e8455ddd
Reported-by: Gisle Vanem Closes #6376
This commit is contained in:
parent
ec424f311a
commit
8ab78f720a
@ -49,17 +49,24 @@ struct conncache {
|
|||||||
#ifdef CURLDEBUG
|
#ifdef CURLDEBUG
|
||||||
/* the debug versions of these macros make extra certain that the lock is
|
/* the debug versions of these macros make extra certain that the lock is
|
||||||
never doubly locked or unlocked */
|
never doubly locked or unlocked */
|
||||||
#define CONNCACHE_LOCK(x) if((x)->share) { \
|
#define CONNCACHE_LOCK(x) \
|
||||||
Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE); \
|
do { \
|
||||||
DEBUGASSERT(!(x)->state.conncache_lock); \
|
if((x)->share) { \
|
||||||
(x)->state.conncache_lock = TRUE; \
|
Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, \
|
||||||
}
|
CURL_LOCK_ACCESS_SINGLE); \
|
||||||
|
DEBUGASSERT(!(x)->state.conncache_lock); \
|
||||||
|
(x)->state.conncache_lock = TRUE; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define CONNCACHE_UNLOCK(x) if((x)->share) { \
|
#define CONNCACHE_UNLOCK(x) \
|
||||||
DEBUGASSERT((x)->state.conncache_lock); \
|
do { \
|
||||||
(x)->state.conncache_lock = FALSE; \
|
if((x)->share) { \
|
||||||
Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT); \
|
DEBUGASSERT((x)->state.conncache_lock); \
|
||||||
}
|
(x)->state.conncache_lock = FALSE; \
|
||||||
|
Curl_share_unlock((x), CURL_LOCK_DATA_CONNECT); \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
#else
|
#else
|
||||||
#define CONNCACHE_LOCK(x) if((x)->share) \
|
#define CONNCACHE_LOCK(x) if((x)->share) \
|
||||||
Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE)
|
Curl_share_lock((x), CURL_LOCK_DATA_CONNECT, CURL_LOCK_ACCESS_SINGLE)
|
||||||
|
@ -44,13 +44,15 @@
|
|||||||
#include "memdebug.h"
|
#include "memdebug.h"
|
||||||
|
|
||||||
#define HMAC_SHA256(k, kl, d, dl, o) \
|
#define HMAC_SHA256(k, kl, d, dl, o) \
|
||||||
if(Curl_hmacit(Curl_HMAC_SHA256, (unsigned char *)k, \
|
do { \
|
||||||
(unsigned int)kl, \
|
if(Curl_hmacit(Curl_HMAC_SHA256, (unsigned char *)k, \
|
||||||
(unsigned char *)d, \
|
(unsigned int)kl, \
|
||||||
(unsigned int)dl, o) != CURLE_OK) { \
|
(unsigned char *)d, \
|
||||||
ret = CURLE_OUT_OF_MEMORY; \
|
(unsigned int)dl, o) != CURLE_OK) { \
|
||||||
goto free_all; \
|
ret = CURLE_OUT_OF_MEMORY; \
|
||||||
}
|
goto free_all; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define PROVIDER_MAX_L 16
|
#define PROVIDER_MAX_L 16
|
||||||
#define REQUEST_TYPE_L (PROVIDER_MAX_L + sizeof("4_request"))
|
#define REQUEST_TYPE_L (PROVIDER_MAX_L + sizeof("4_request"))
|
||||||
|
12
lib/smb.c
12
lib/smb.c
@ -124,13 +124,17 @@ const struct Curl_handler Curl_handler_smbs = {
|
|||||||
|
|
||||||
/* Append a string to an SMB message */
|
/* Append a string to an SMB message */
|
||||||
#define MSGCAT(str) \
|
#define MSGCAT(str) \
|
||||||
strcpy(p, (str)); \
|
do { \
|
||||||
p += strlen(str);
|
strcpy(p, (str)); \
|
||||||
|
p += strlen(str); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
/* Append a null-terminated string to an SMB message */
|
/* Append a null-terminated string to an SMB message */
|
||||||
#define MSGCATNULL(str) \
|
#define MSGCATNULL(str) \
|
||||||
strcpy(p, (str)); \
|
do { \
|
||||||
p += strlen(str) + 1;
|
strcpy(p, (str)); \
|
||||||
|
p += strlen(str) + 1; \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
/* SMB is mostly little endian */
|
/* SMB is mostly little endian */
|
||||||
#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
|
#if (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) || \
|
||||||
|
@ -1232,10 +1232,7 @@ CURLcode Curl_readwrite(struct connectdata *conn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
k->now = Curl_now();
|
k->now = Curl_now();
|
||||||
if(didwhat) {
|
if(!didwhat) {
|
||||||
;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
/* no read no write, this is a timeout? */
|
/* no read no write, this is a timeout? */
|
||||||
if(k->exp100 == EXP100_AWAITING_CONTINUE) {
|
if(k->exp100 == EXP100_AWAITING_CONTINUE) {
|
||||||
/* This should allow some time for the header to arrive, but only a
|
/* This should allow some time for the header to arrive, but only a
|
||||||
|
@ -1151,10 +1151,7 @@ ConnectionExists(struct Curl_easy *data,
|
|||||||
if(bundle->multiuse == BUNDLE_MULTIPLEX)
|
if(bundle->multiuse == BUNDLE_MULTIPLEX)
|
||||||
multiplexed = CONN_INUSE(check);
|
multiplexed = CONN_INUSE(check);
|
||||||
|
|
||||||
if(canmultiplex) {
|
if(!canmultiplex) {
|
||||||
;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(multiplexed) {
|
if(multiplexed) {
|
||||||
/* can only happen within multi handles, and means that another easy
|
/* can only happen within multi handles, and means that another easy
|
||||||
handle is using this connection */
|
handle is using this connection */
|
||||||
|
14
lib/urlapi.c
14
lib/urlapi.c
@ -983,12 +983,14 @@ void curl_url_cleanup(CURLU *u)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define DUP(dest, src, name) \
|
#define DUP(dest, src, name) \
|
||||||
if(src->name) { \
|
do { \
|
||||||
dest->name = strdup(src->name); \
|
if(src->name) { \
|
||||||
if(!dest->name) \
|
dest->name = strdup(src->name); \
|
||||||
goto fail; \
|
if(!dest->name) \
|
||||||
}
|
goto fail; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
CURLU *curl_url_dup(CURLU *in)
|
CURLU *curl_url_dup(CURLU *in)
|
||||||
{
|
{
|
||||||
|
@ -61,12 +61,14 @@
|
|||||||
It converts digest text to ASCII so the MD5 will be correct for
|
It converts digest text to ASCII so the MD5 will be correct for
|
||||||
what ultimately goes over the network.
|
what ultimately goes over the network.
|
||||||
*/
|
*/
|
||||||
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
|
#define CURL_OUTPUT_DIGEST_CONV(a, b) \
|
||||||
result = Curl_convert_to_network(a, b, strlen(b)); \
|
do { \
|
||||||
if(result) { \
|
result = Curl_convert_to_network(a, b, strlen(b)); \
|
||||||
free(b); \
|
if(result) { \
|
||||||
return result; \
|
free(b); \
|
||||||
}
|
return result; \
|
||||||
|
} \
|
||||||
|
} while(0)
|
||||||
#endif /* !USE_WINDOWS_SSPI */
|
#endif /* !USE_WINDOWS_SSPI */
|
||||||
|
|
||||||
bool Curl_auth_digest_get_pair(const char *str, char *value, char *content,
|
bool Curl_auth_digest_get_pair(const char *str, char *value, char *content,
|
||||||
|
@ -75,17 +75,21 @@
|
|||||||
(1<<CURL_LOCK_DATA_SSL_SESSION)))
|
(1<<CURL_LOCK_DATA_SSL_SESSION)))
|
||||||
|
|
||||||
#define CLONE_STRING(var) \
|
#define CLONE_STRING(var) \
|
||||||
if(source->var) { \
|
do { \
|
||||||
dest->var = strdup(source->var); \
|
if(source->var) { \
|
||||||
if(!dest->var) \
|
dest->var = strdup(source->var); \
|
||||||
return FALSE; \
|
if(!dest->var) \
|
||||||
} \
|
return FALSE; \
|
||||||
else \
|
} \
|
||||||
dest->var = NULL;
|
else \
|
||||||
|
dest->var = NULL; \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
#define CLONE_BLOB(var) \
|
#define CLONE_BLOB(var) \
|
||||||
if(blobdup(&dest->var, source->var)) \
|
do { \
|
||||||
return FALSE;
|
if(blobdup(&dest->var, source->var)) \
|
||||||
|
return FALSE; \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
static CURLcode blobdup(struct curl_blob **dest,
|
static CURLcode blobdup(struct curl_blob **dest,
|
||||||
struct curl_blob *src)
|
struct curl_blob *src)
|
||||||
|
@ -720,19 +720,22 @@ static int get_param_part(struct OperationConfig *config, char endchar,
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
/* Convenience macros for null pointer check. */
|
/* Convenience macros for null pointer check. */
|
||||||
#define NULL_CHECK(ptr, init, retcode) { \
|
#define NULL_CHECK(ptr, init, retcode) \
|
||||||
(ptr) = (init); \
|
do { \
|
||||||
if(!(ptr)) { \
|
(ptr) = (init); \
|
||||||
warnf(config->global, "out of memory!\n"); \
|
if(!(ptr)) { \
|
||||||
curl_slist_free_all(headers); \
|
warnf(config->global, "out of memory!\n"); \
|
||||||
Curl_safefree(contents); \
|
curl_slist_free_all(headers); \
|
||||||
return retcode; \
|
Curl_safefree(contents); \
|
||||||
} \
|
return retcode; \
|
||||||
}
|
} \
|
||||||
#define SET_TOOL_MIME_PTR(m, field, retcode) { \
|
} while(0)
|
||||||
if(field) \
|
|
||||||
NULL_CHECK((m)->field, strdup(field), retcode); \
|
#define SET_TOOL_MIME_PTR(m, field, retcode) \
|
||||||
}
|
do { \
|
||||||
|
if(field) \
|
||||||
|
NULL_CHECK((m)->field, strdup(field), retcode); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
int formparse(struct OperationConfig *config,
|
int formparse(struct OperationConfig *config,
|
||||||
const char *input,
|
const char *input,
|
||||||
|
@ -362,10 +362,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if(config->synthetic_error) {
|
if(!config->synthetic_error && result && global->showerror) {
|
||||||
;
|
|
||||||
}
|
|
||||||
else if(result && global->showerror) {
|
|
||||||
fprintf(global->errors, "curl: (%d) %s\n", result,
|
fprintf(global->errors, "curl: (%d) %s\n", result,
|
||||||
(per->errorbuffer[0]) ? per->errorbuffer :
|
(per->errorbuffer[0]) ? per->errorbuffer :
|
||||||
curl_easy_strerror(result));
|
curl_easy_strerror(result));
|
||||||
|
@ -74,7 +74,7 @@ static void jsonEscape(FILE *stream, const char *in)
|
|||||||
fputc(*i, stream);
|
fputc(*i, stream);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user