Skip to content

Commit df60148

Browse files
committed
clang-tidy: enable more checks, fix fallouts
- enable three checks: - bugprone-invalid-enum-default-initialization - bugprone-sizeof-expression - readability-inconsistent-declaration-parameter-name (strict) - fix remaining discrepancies with arg names in prototypes and implementation, in strict mode. - document reason for some checks tested but not enabled. Closes #20794
1 parent e0dd6eb commit df60148

34 files changed

Lines changed: 222 additions & 209 deletions

‎.clang-tidy.yml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Checks:
1616
- bugprone-assignment-in-if-condition
1717
- bugprone-chained-comparison
1818
- bugprone-dynamic-static-initializers
19+
- bugprone-invalid-enum-default-initialization
1920
- bugprone-macro-parentheses
2021
- bugprone-macro-repeated-side-effects
2122
- bugprone-misplaced-operator-in-strlen-in-alloc
@@ -24,16 +25,25 @@ Checks:
2425
- bugprone-posix-return
2526
- bugprone-redundant-branch-condition
2627
- bugprone-signed-char-misuse
28+
- bugprone-sizeof-expression
2729
- bugprone-suspicious-enum-usage
2830
- bugprone-suspicious-memset-usage
2931
- bugprone-suspicious-missing-comma
3032
- bugprone-suspicious-realloc-usage
3133
- bugprone-suspicious-semicolon
34+
# bugprone-unchecked-string-to-number-conversion # needs converting sscanf to strtol or curlx_str_*
3235
- misc-const-correctness
3336
- misc-header-include-cycle
37+
# misc-redundant-expression # undesired hits due to system macros, e.g. due to POLLIN == POLLRDNORM | POLLRDBAND, then or-ing all three
3438
- portability-*
3539
- readability-duplicate-include
40+
# readability-else-after-return
41+
# readability-enum-initial-value
42+
# readability-function-cognitive-complexity
43+
- readability-inconsistent-declaration-parameter-name
44+
# readability-misleading-indentation # too many false positives and oddball/conditional source
3645
- readability-named-parameter
46+
# readability-redundant-casting # false positives in types that change from platform to platform, even with IgnoreTypeAliases: true
3747
- readability-redundant-control-flow
3848
- readability-redundant-declaration
3949
- readability-redundant-function-ptr-dereference
@@ -44,5 +54,6 @@ Checks:
4454

4555
CheckOptions:
4656
misc-header-include-cycle.IgnoredFilesList: 'curl/curl.h'
57+
readability-inconsistent-declaration-parameter-name.Strict: true
4758

4859
HeaderFilterRegex: '.*' # Default in v22.1.0+

‎docs/libcurl/curl_easy_header.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ curl_easy_header - get an HTTP header
2626

2727
CURLHcode curl_easy_header(CURL *easy,
2828
const char *name,
29-
size_t index,
29+
size_t nameindex,
3030
unsigned int origin,
3131
int request,
3232
struct curl_header **hout);
@@ -38,10 +38,10 @@ curl_easy_header(3) returns a pointer to a "curl_header" struct in **hout**
3838
with data for the HTTP response header *name*. The case insensitive
3939
null-terminated header name should be specified without colon.
4040
41-
*index* 0 means asking for the first instance of the header. If the returned
42-
header struct has **amount** set larger than 1, it means there are more
43-
instances of the same header name available to get. Asking for a too big index
44-
makes **CURLHE_BADINDEX** get returned.
41+
*nameindex* 0 means asking for the first instance of the header. If the
42+
returned header struct has **amount** set larger than 1, it means there are
43+
more instances of the same header name available to get. Asking for a too big
44+
index makes **CURLHE_BADINDEX** get returned.
4545
4646
The *origin* argument is for specifying which headers to receive, as a single
4747
HTTP transfer might provide headers from several different places and they may

‎docs/libcurl/curl_easy_pause.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ curl_easy_pause - pause and unpause a connection
2121
~~~c
2222
#include <curl/curl.h>
2323

24-
CURLcode curl_easy_pause(CURL *handle, int bitmask);
24+
CURLcode curl_easy_pause(CURL *handle, int action);
2525
~~~
2626
2727
# DESCRIPTION
@@ -54,7 +54,7 @@ A paused transfer is excluded from low speed cancels via the
5454
CURLOPT_LOW_SPEED_LIMIT(3) option and unpausing a transfer resets the
5555
time period required for the low speed limit to be met.
5656
57-
The **bitmask** argument is a set of bits that sets the new state of the
57+
The **action** argument is a set of bits that sets the new state of the
5858
connection. The following bits can be used:
5959
6060
## CURLPAUSE_RECV

‎docs/libcurl/curl_multi_timeout.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ curl_multi_socket_action(3) function with the **sockfd** argument set
3737
to CURL_SOCKET_TIMEOUT, or call curl_multi_perform(3) if you are using
3838
the simpler and older multi interface approach.
3939
40-
The timeout value returned in the long **timeout** points to, is in number
40+
The timeout value returned in the long **timeout_ms** points to, is in number
4141
of milliseconds at this moment. If 0, it means you should proceed immediately
4242
without waiting for anything. If it returns -1, there is no timeout at all set.
4343

‎include/curl/curl.h‎

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,7 @@ CURL_EXTERN char *curl_version(void);
26952695
* %XX versions). This function returns a new allocated string or NULL if an
26962696
* error occurred.
26972697
*/
2698-
CURL_EXTERN char *curl_easy_escape(CURL *handle,
2698+
CURL_EXTERN char *curl_easy_escape(CURL *curl,
26992699
const char *string,
27002700
int length);
27012701

@@ -2714,9 +2714,9 @@ CURL_EXTERN char *curl_escape(const char *string,
27142714
* Conversion Note: On non-ASCII platforms the ASCII %XX codes are
27152715
* converted into the host encoding.
27162716
*/
2717-
CURL_EXTERN char *curl_easy_unescape(CURL *handle,
2717+
CURL_EXTERN char *curl_easy_unescape(CURL *curl,
27182718
const char *string,
2719-
int length,
2719+
int inlength,
27202720
int *outlength);
27212721

27222722
/* the previous version */
@@ -3076,9 +3076,8 @@ typedef enum {
30763076
} CURLSHoption;
30773077

30783078
CURL_EXTERN CURLSH *curl_share_init(void);
3079-
CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *share, CURLSHoption option,
3080-
...);
3081-
CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *share);
3079+
CURL_EXTERN CURLSHcode curl_share_setopt(CURLSH *sh, CURLSHoption option, ...);
3080+
CURL_EXTERN CURLSHcode curl_share_cleanup(CURLSH *sh);
30823081

30833082
/****************************************************************************
30843083
* Structures for querying information about the curl library at runtime.
@@ -3246,10 +3245,10 @@ CURL_EXTERN const char *curl_share_strerror(CURLSHcode error);
32463245
* DESCRIPTION
32473246
*
32483247
* The curl_easy_pause function pauses or unpauses transfers. Select the new
3249-
* state by setting the bitmask, use the convenience defines below.
3248+
* state by setting the action bitmask, use the convenience defines below.
32503249
*
32513250
*/
3252-
CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
3251+
CURL_EXTERN CURLcode curl_easy_pause(CURL *curl, int action);
32533252

32543253
#define CURLPAUSE_RECV (1 << 0)
32553254
#define CURLPAUSE_RECV_CONT 0
@@ -3268,7 +3267,7 @@ CURL_EXTERN CURLcode curl_easy_pause(CURL *handle, int bitmask);
32683267
* The curl_easy_ssls_import function adds a previously exported SSL session
32693268
* to the SSL session cache of the easy handle (or the underlying share).
32703269
*/
3271-
CURL_EXTERN CURLcode curl_easy_ssls_import(CURL *handle,
3270+
CURL_EXTERN CURLcode curl_easy_ssls_import(CURL *curl,
32723271
const char *session_key,
32733272
const unsigned char *shmac,
32743273
size_t shmac_len,
@@ -3277,7 +3276,7 @@ CURL_EXTERN CURLcode curl_easy_ssls_import(CURL *handle,
32773276

32783277
/* This is the curl_ssls_export_cb callback prototype. It
32793278
* is passed to curl_easy_ssls_export() to extract SSL sessions/tickets. */
3280-
typedef CURLcode curl_ssls_export_cb(CURL *handle,
3279+
typedef CURLcode curl_ssls_export_cb(CURL *curl,
32813280
void *userptr,
32823281
const char *session_key,
32833282
const unsigned char *shmac,
@@ -3299,7 +3298,7 @@ typedef CURLcode curl_ssls_export_cb(CURL *handle,
32993298
* callback.
33003299
*
33013300
*/
3302-
CURL_EXTERN CURLcode curl_easy_ssls_export(CURL *handle,
3301+
CURL_EXTERN CURLcode curl_easy_ssls_export(CURL *curl,
33033302
curl_ssls_export_cb *export_fn,
33043303
void *userptr);
33053304

‎include/curl/header.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ typedef enum {
5555
CURLHE_NOT_BUILT_IN /* if API was disabled in the build */
5656
} CURLHcode;
5757

58-
CURL_EXTERN CURLHcode curl_easy_header(CURL *easy,
58+
CURL_EXTERN CURLHcode curl_easy_header(CURL *curl,
5959
const char *name,
60-
size_t index,
60+
size_t nameindex,
6161
unsigned int origin,
6262
int request,
6363
struct curl_header **hout);
6464

65-
CURL_EXTERN struct curl_header *curl_easy_nextheader(CURL *easy,
65+
CURL_EXTERN struct curl_header *curl_easy_nextheader(CURL *curl,
6666
unsigned int origin,
6767
int request,
6868
struct curl_header *prev);

‎include/curl/multi.h‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ CURL_EXTERN CURLM *curl_multi_init(void);
132132
*
133133
* Returns: CURLMcode type, general multi error code.
134134
*/
135-
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
136-
CURL *curl_handle);
135+
CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *m,
136+
CURL *curl);
137137

138138
/*
139139
* Name: curl_multi_remove_handle()
@@ -142,8 +142,8 @@ CURL_EXTERN CURLMcode curl_multi_add_handle(CURLM *multi_handle,
142142
*
143143
* Returns: CURLMcode type, general multi error code.
144144
*/
145-
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
146-
CURL *curl_handle);
145+
CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *m,
146+
CURL *curl);
147147

148148
/*
149149
* Name: curl_multi_fdset()
@@ -154,7 +154,7 @@ CURL_EXTERN CURLMcode curl_multi_remove_handle(CURLM *multi_handle,
154154
*
155155
* Returns: CURLMcode type, general multi error code.
156156
*/
157-
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
157+
CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *m,
158158
fd_set *read_fd_set,
159159
fd_set *write_fd_set,
160160
fd_set *exc_fd_set,
@@ -168,7 +168,7 @@ CURL_EXTERN CURLMcode curl_multi_fdset(CURLM *multi_handle,
168168
*
169169
* Returns: CURLMcode type, general multi error code.
170170
*/
171-
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
171+
CURL_EXTERN CURLMcode curl_multi_wait(CURLM *m,
172172
struct curl_waitfd extra_fds[],
173173
unsigned int extra_nfds,
174174
int timeout_ms,
@@ -182,7 +182,7 @@ CURL_EXTERN CURLMcode curl_multi_wait(CURLM *multi_handle,
182182
*
183183
* Returns: CURLMcode type, general multi error code.
184184
*/
185-
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
185+
CURL_EXTERN CURLMcode curl_multi_poll(CURLM *m,
186186
struct curl_waitfd extra_fds[],
187187
unsigned int extra_nfds,
188188
int timeout_ms,
@@ -195,7 +195,7 @@ CURL_EXTERN CURLMcode curl_multi_poll(CURLM *multi_handle,
195195
*
196196
* Returns: CURLMcode type, general multi error code.
197197
*/
198-
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
198+
CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *m);
199199

200200
/*
201201
* Name: curl_multi_perform()
@@ -213,7 +213,7 @@ CURL_EXTERN CURLMcode curl_multi_wakeup(CURLM *multi_handle);
213213
* still have occurred problems on individual transfers even when
214214
* this returns OK.
215215
*/
216-
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
216+
CURL_EXTERN CURLMcode curl_multi_perform(CURLM *m,
217217
int *running_handles);
218218

219219
/*
@@ -226,7 +226,7 @@ CURL_EXTERN CURLMcode curl_multi_perform(CURLM *multi_handle,
226226
*
227227
* Returns: CURLMcode type, general multi error code.
228228
*/
229-
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
229+
CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *m);
230230

231231
/*
232232
* Name: curl_multi_info_read()
@@ -256,7 +256,7 @@ CURL_EXTERN CURLMcode curl_multi_cleanup(CURLM *multi_handle);
256256
* queue (after this read) in the integer the second argument points
257257
* to.
258258
*/
259-
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *multi_handle,
259+
CURL_EXTERN CURLMsg *curl_multi_info_read(CURLM *m,
260260
int *msgs_in_queue);
261261

262262
/*
@@ -308,21 +308,21 @@ typedef int (*curl_socket_callback)(CURL *easy, /* easy handle */
308308
*
309309
* Returns: The callback should return zero.
310310
*/
311-
typedef int (*curl_multi_timer_callback)(CURLM *multi, /* multi handle */
311+
typedef int (*curl_multi_timer_callback)(CURLM *m, /* multi handle */
312312
long timeout_ms, /* see above */
313313
void *userp); /* private callback
314314
pointer */
315315

316316
CURL_EXTERN CURLMcode CURL_DEPRECATED(7.19.5, "Use curl_multi_socket_action()")
317-
curl_multi_socket(CURLM *multi_handle, curl_socket_t s, int *running_handles);
317+
curl_multi_socket(CURLM *m, curl_socket_t s, int *running_handles);
318318

319-
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *multi_handle,
319+
CURL_EXTERN CURLMcode curl_multi_socket_action(CURLM *m,
320320
curl_socket_t s,
321321
int ev_bitmask,
322322
int *running_handles);
323323

324324
CURL_EXTERN CURLMcode CURL_DEPRECATED(7.19.5, "Use curl_multi_socket_action()")
325-
curl_multi_socket_all(CURLM *multi_handle, int *running_handles);
325+
curl_multi_socket_all(CURLM *m, int *running_handles);
326326

327327
#ifndef CURL_ALLOW_OLD_MULTI_SOCKET
328328
/* This macro below was added in 7.16.3 to push users who recompile to use
@@ -340,8 +340,8 @@ curl_multi_socket_all(CURLM *multi_handle, int *running_handles);
340340
*
341341
* Returns: CURLM error code.
342342
*/
343-
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *multi_handle,
344-
long *milliseconds);
343+
CURL_EXTERN CURLMcode curl_multi_timeout(CURLM *m,
344+
long *timeout_ms);
345345

346346
typedef enum {
347347
/* This is the socket callback function pointer */
@@ -435,7 +435,7 @@ typedef enum {
435435
*
436436
* Returns: CURLM error code.
437437
*/
438-
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
438+
CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *m,
439439
CURLMoption option, ...);
440440

441441
/*
@@ -447,7 +447,7 @@ CURL_EXTERN CURLMcode curl_multi_setopt(CURLM *multi_handle,
447447
*
448448
* Returns: CURLM error code.
449449
*/
450-
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
450+
CURL_EXTERN CURLMcode curl_multi_assign(CURLM *m,
451451
curl_socket_t sockfd, void *sockp);
452452

453453
/*
@@ -460,7 +460,7 @@ CURL_EXTERN CURLMcode curl_multi_assign(CURLM *multi_handle,
460460
*
461461
* Returns: NULL on failure, otherwise a CURL **array pointer
462462
*/
463-
CURL_EXTERN CURL **curl_multi_get_handles(CURLM *multi_handle);
463+
CURL_EXTERN CURL **curl_multi_get_handles(CURLM *m);
464464

465465
typedef enum {
466466
CURLMINFO_NONE, /* first, never use this */
@@ -489,7 +489,7 @@ typedef enum {
489489
*
490490
* Returns: CULRM_OK or error when value could not be obtained.
491491
*/
492-
CURL_EXTERN CURLMcode curl_multi_get_offt(CURLM *multi_handle,
492+
CURL_EXTERN CURLMcode curl_multi_get_offt(CURLM *m,
493493
CURLMinfo_offt info,
494494
curl_off_t *pvalue);
495495

@@ -528,7 +528,7 @@ typedef int (*curl_push_callback)(CURL *parent,
528528
*
529529
* Returns: CURLMcode type, general multi error code.
530530
*/
531-
CURL_EXTERN CURLMcode curl_multi_waitfds(CURLM *multi,
531+
CURL_EXTERN CURLMcode curl_multi_waitfds(CURLM *m,
532532
struct curl_waitfd *ufds,
533533
unsigned int size,
534534
unsigned int *fd_count);
@@ -542,15 +542,15 @@ CURL_EXTERN CURLMcode curl_multi_waitfds(CURLM *multi,
542542
/*
543543
* Callback to install via CURLMOPT_NOTIFYFUNCTION.
544544
*/
545-
typedef void (*curl_notify_callback)(CURLM *multi,
545+
typedef void (*curl_notify_callback)(CURLM *m,
546546
unsigned int notification,
547547
CURL *easy,
548548
void *user_data);
549549

550-
CURL_EXTERN CURLMcode curl_multi_notify_disable(CURLM *multi,
550+
CURL_EXTERN CURLMcode curl_multi_notify_disable(CURLM *m,
551551
unsigned int notification);
552552

553-
CURL_EXTERN CURLMcode curl_multi_notify_enable(CURLM *multi,
553+
CURL_EXTERN CURLMcode curl_multi_notify_enable(CURLM *m,
554554
unsigned int notification);
555555

556556
#ifdef __cplusplus

‎include/curl/urlapi.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ CURL_EXTERN CURLU *curl_url(void);
117117
* the URL parsing. It does not free strings previously returned with the URL
118118
* API.
119119
*/
120-
CURL_EXTERN void curl_url_cleanup(CURLU *handle);
120+
CURL_EXTERN void curl_url_cleanup(CURLU *u);
121121

122122
/*
123123
* curl_url_dup() duplicates a CURLU handle and returns a new copy. The new
@@ -130,15 +130,15 @@ CURL_EXTERN CURLU *curl_url_dup(const CURLU *in);
130130
* handle. Returns error code. The returned pointer MUST be freed with
131131
* curl_free() afterwards.
132132
*/
133-
CURL_EXTERN CURLUcode curl_url_get(const CURLU *handle, CURLUPart what,
133+
CURL_EXTERN CURLUcode curl_url_get(const CURLU *u, CURLUPart what,
134134
char **part, unsigned int flags);
135135

136136
/*
137137
* curl_url_set() sets a specific part of the URL in a CURLU handle. Returns
138138
* error code. The passed in string is copied. Passing a NULL instead of
139139
* a part string, clears that part.
140140
*/
141-
CURL_EXTERN CURLUcode curl_url_set(CURLU *handle, CURLUPart what,
141+
CURL_EXTERN CURLUcode curl_url_set(CURLU *u, CURLUPart what,
142142
const char *part, unsigned int flags);
143143

144144
/*

0 commit comments

Comments
 (0)