Skip to content

Commit b5548c5

Browse files
authored
fix warnings (#529)
1 parent dd18dc8 commit b5548c5

17 files changed

+105
-95
lines changed

include/ada/ada_idna.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ namespace ada::idna {
8888
/**
8989
* @see https://www.unicode.org/reports/tr46/#Validity_Criteria
9090
*/
91-
bool is_label_valid(const std::u32string_view label);
91+
bool is_label_valid(std::u32string_view label);
9292

9393
} // namespace ada::idna
9494

include/ada/character_sets-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,4 +513,4 @@ ada_really_inline bool bit_at(const uint8_t a[], const uint8_t i) {
513513

514514
} // namespace ada::character_sets
515515

516-
#endif // ADA_CHARACTER_SETS_H
516+
#endif // ADA_CHARACTER_SETS_INL_H

include/ada/character_sets.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88
#define ADA_CHARACTER_SETS_H
99

1010
#include "ada/common_defs.h"
11-
#include <stdint.h>
11+
#include <cstdint>
1212

1313
/**
1414
* @namespace ada::character_sets
1515
* @brief Includes the definitions for unicode character sets.
1616
*/
1717
namespace ada::character_sets {
18-
ada_really_inline bool bit_at(const uint8_t a[], const uint8_t i);
18+
ada_really_inline bool bit_at(const uint8_t a[], uint8_t i);
1919
} // namespace ada::character_sets
2020

2121
#endif // ADA_CHARACTER_SETS_H

include/ada/helpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ ada_really_inline bool shorten_path(std::string_view& path,
7070
*
7171
* @see https://url.spec.whatwg.org/
7272
*/
73-
ada_really_inline void parse_prepared_path(const std::string_view input,
73+
ada_really_inline void parse_prepared_path(std::string_view input,
7474
ada::scheme::type type,
7575
std::string& path);
7676

include/ada/scheme-inl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept {
6060

6161
} // namespace ada::scheme
6262

63-
#endif // ADA_SCHEME_H
63+
#endif // ADA_SCHEME_INL_H

include/ada/serializers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std::string ipv6(const std::array<uint16_t, 8>& address) noexcept;
3838
* network address.
3939
* @see https://url.spec.whatwg.org/#concept-ipv4-serializer
4040
*/
41-
std::string ipv4(const uint64_t address) noexcept;
41+
std::string ipv4(uint64_t address) noexcept;
4242

4343
} // namespace ada::serializers
4444

include/ada/unicode.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ ada_really_inline bool has_tabs_or_newline(
7878
* Checks if the input is a forbidden host code point.
7979
* @see https://url.spec.whatwg.org/#forbidden-host-code-point
8080
*/
81-
ada_really_inline constexpr bool is_forbidden_host_code_point(
82-
const char c) noexcept;
81+
ada_really_inline constexpr bool is_forbidden_host_code_point(char c) noexcept;
8382

8483
/**
8584
* Checks if the input contains a forbidden domain code point.
@@ -103,20 +102,20 @@ contains_forbidden_domain_code_point_or_upper(const char* input,
103102
* @see https://url.spec.whatwg.org/#forbidden-domain-code-point
104103
*/
105104
ada_really_inline constexpr bool is_forbidden_domain_code_point(
106-
const char c) noexcept;
105+
char c) noexcept;
107106

108107
/**
109108
* Checks if the input is alphanumeric, '+', '-' or '.'
110109
*/
111-
ada_really_inline constexpr bool is_alnum_plus(const char c) noexcept;
110+
ada_really_inline constexpr bool is_alnum_plus(char c) noexcept;
112111

113112
/**
114113
* @details An ASCII hex digit is an ASCII upper hex digit or ASCII lower hex
115114
* digit. An ASCII upper hex digit is an ASCII digit or a code point in the
116115
* range U+0041 (A) to U+0046 (F), inclusive. An ASCII lower hex digit is an
117116
* ASCII digit or a code point in the range U+0061 (a) to U+0066 (f), inclusive.
118117
*/
119-
ada_really_inline constexpr bool is_ascii_hex_digit(const char c) noexcept;
118+
ada_really_inline constexpr bool is_ascii_hex_digit(char c) noexcept;
120119

121120
/**
122121
* Checks if the input is a C0 control or space character.
@@ -125,33 +124,33 @@ ada_really_inline constexpr bool is_ascii_hex_digit(const char c) noexcept;
125124
* A C0 control is a code point in the range U+0000 NULL to U+001F INFORMATION
126125
* SEPARATOR ONE, inclusive.
127126
*/
128-
ada_really_inline constexpr bool is_c0_control_or_space(const char c) noexcept;
127+
ada_really_inline constexpr bool is_c0_control_or_space(char c) noexcept;
129128

130129
/**
131130
* Checks if the input is a ASCII tab or newline character.
132131
*
133132
* @details An ASCII tab or newline is U+0009 TAB, U+000A LF, or U+000D CR.
134133
*/
135-
ada_really_inline constexpr bool is_ascii_tab_or_newline(const char c) noexcept;
134+
ada_really_inline constexpr bool is_ascii_tab_or_newline(char c) noexcept;
136135

137136
/**
138137
* @details A double-dot path segment must be ".." or an ASCII case-insensitive
139138
* match for ".%2e", "%2e.", or "%2e%2e".
140139
*/
141140
ada_really_inline ada_constexpr bool is_double_dot_path_segment(
142-
const std::string_view input) noexcept;
141+
std::string_view input) noexcept;
143142

144143
/**
145144
* @details A single-dot path segment must be "." or an ASCII case-insensitive
146145
* match for "%2e".
147146
*/
148147
ada_really_inline constexpr bool is_single_dot_path_segment(
149-
const std::string_view input) noexcept;
148+
std::string_view input) noexcept;
150149

151150
/**
152151
* @details ipv4 character might contain 0-9 or a-f character ranges.
153152
*/
154-
ada_really_inline constexpr bool is_lowercase_hex(const char c) noexcept;
153+
ada_really_inline constexpr bool is_lowercase_hex(char c) noexcept;
155154

156155
/**
157156
* @details Convert hex to binary. Caller is responsible to ensure that
@@ -167,20 +166,20 @@ ada_really_inline unsigned constexpr convert_hex_to_binary(char c) noexcept;
167166
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L245
168167
* @see https://encoding.spec.whatwg.org/#utf-8-decode-without-bom
169168
*/
170-
std::string percent_decode(const std::string_view input, size_t first_percent);
169+
std::string percent_decode(std::string_view input, size_t first_percent);
171170

172171
/**
173172
* Returns a percent-encoding string whether percent encoding was needed or not.
174173
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L226
175174
*/
176-
std::string percent_encode(const std::string_view input,
175+
std::string percent_encode(std::string_view input,
177176
const uint8_t character_set[]);
178177
/**
179178
* Returns a percent-encoded string version of input, while starting the percent
180179
* encoding at the provided index.
181180
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L226
182181
*/
183-
std::string percent_encode(const std::string_view input,
182+
std::string percent_encode(std::string_view input,
184183
const uint8_t character_set[], size_t index);
185184
/**
186185
* Returns true if percent encoding was needed, in which case, we store
@@ -190,13 +189,13 @@ std::string percent_encode(const std::string_view input,
190189
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L226
191190
*/
192191
template <bool append>
193-
bool percent_encode(const std::string_view input, const uint8_t character_set[],
192+
bool percent_encode(std::string_view input, const uint8_t character_set[],
194193
std::string& out);
195194
/**
196195
* Returns the index at which percent encoding should start, or (equivalently),
197196
* the length of the prefix that does not require percent encoding.
198197
*/
199-
ada_really_inline size_t percent_encode_index(const std::string_view input,
198+
ada_really_inline size_t percent_encode_index(std::string_view input,
200199
const uint8_t character_set[]);
201200
/**
202201
* Lowers the string in-place, assuming that the content is ASCII.

include/ada/url-inl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ inline std::ostream &operator<<(std::ostream &out, const ada::url &u) {
3939
return out << u.to_string();
4040
}
4141

42-
size_t url::get_pathname_length() const noexcept { return path.size(); }
42+
[[nodiscard]] size_t url::get_pathname_length() const noexcept {
43+
return path.size();
44+
}
4345

4446
[[nodiscard]] ada_really_inline ada::url_components url::get_components()
4547
const noexcept {

include/ada/url.h

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct url : url_base {
4141
url(url &&u) noexcept = default;
4242
url &operator=(url &&u) noexcept = default;
4343
url &operator=(const url &u) = default;
44-
~url() = default;
44+
~url() override = default;
4545

4646
/**
4747
* @private
@@ -102,7 +102,7 @@ struct url : url_base {
102102
/**
103103
* Returns a JSON string representation of this URL.
104104
*/
105-
std::string to_string() const override;
105+
[[nodiscard]] std::string to_string() const override;
106106

107107
/**
108108
* @see https://url.spec.whatwg.org/#dom-url-href
@@ -149,15 +149,15 @@ struct url : url_base {
149149
* @return a newly allocated string.
150150
* @see https://url.spec.whatwg.org/#dom-url-pathname
151151
*/
152-
[[nodiscard]] const std::string_view get_pathname() const noexcept;
152+
[[nodiscard]] std::string_view get_pathname() const noexcept;
153153

154154
/**
155155
* Compute the pathname length in bytes without instantiating a view or a
156156
* string.
157157
* @return size of the pathname in bytes
158158
* @see https://url.spec.whatwg.org/#dom-url-pathname
159159
*/
160-
ada_really_inline size_t get_pathname_length() const noexcept;
160+
[[nodiscard]] ada_really_inline size_t get_pathname_length() const noexcept;
161161

162162
/**
163163
* Return U+003F (?), followed by this's URL's query.
@@ -177,60 +177,60 @@ struct url : url_base {
177177
* @return Returns true on successful operation.
178178
* @see https://url.spec.whatwg.org/#dom-url-username
179179
*/
180-
bool set_username(const std::string_view input);
180+
bool set_username(std::string_view input);
181181

182182
/**
183183
* @return Returns true on success.
184184
* @see https://url.spec.whatwg.org/#dom-url-password
185185
*/
186-
bool set_password(const std::string_view input);
186+
bool set_password(std::string_view input);
187187

188188
/**
189189
* @return Returns true on success.
190190
* @see https://url.spec.whatwg.org/#dom-url-port
191191
*/
192-
bool set_port(const std::string_view input);
192+
bool set_port(std::string_view input);
193193

194194
/**
195195
* This function always succeeds.
196196
* @see https://url.spec.whatwg.org/#dom-url-hash
197197
*/
198-
void set_hash(const std::string_view input);
198+
void set_hash(std::string_view input);
199199

200200
/**
201201
* This function always succeeds.
202202
* @see https://url.spec.whatwg.org/#dom-url-search
203203
*/
204-
void set_search(const std::string_view input);
204+
void set_search(std::string_view input);
205205

206206
/**
207207
* @return Returns true on success.
208208
* @see https://url.spec.whatwg.org/#dom-url-search
209209
*/
210-
bool set_pathname(const std::string_view input);
210+
bool set_pathname(std::string_view input);
211211

212212
/**
213213
* @return Returns true on success.
214214
* @see https://url.spec.whatwg.org/#dom-url-host
215215
*/
216-
bool set_host(const std::string_view input);
216+
bool set_host(std::string_view input);
217217

218218
/**
219219
* @return Returns true on success.
220220
* @see https://url.spec.whatwg.org/#dom-url-hostname
221221
*/
222-
bool set_hostname(const std::string_view input);
222+
bool set_hostname(std::string_view input);
223223

224224
/**
225225
* @return Returns true on success.
226226
* @see https://url.spec.whatwg.org/#dom-url-protocol
227227
*/
228-
bool set_protocol(const std::string_view input);
228+
bool set_protocol(std::string_view input);
229229

230230
/**
231231
* @see https://url.spec.whatwg.org/#dom-url-href
232232
*/
233-
bool set_href(const std::string_view input);
233+
bool set_href(std::string_view input);
234234

235235
/**
236236
* The password getter steps are to return this's URL's password.
@@ -301,9 +301,9 @@ struct url : url_base {
301301
inline void update_base_search(std::string_view input,
302302
const uint8_t query_percent_encode_set[]);
303303
inline void update_base_search(std::optional<std::string> input);
304-
inline void update_base_pathname(const std::string_view input);
305-
inline void update_base_username(const std::string_view input);
306-
inline void update_base_password(const std::string_view input);
304+
inline void update_base_pathname(std::string_view input);
305+
inline void update_base_username(std::string_view input);
306+
inline void update_base_password(std::string_view input);
307307
inline void update_base_port(std::optional<uint16_t> input);
308308

309309
/**
@@ -349,9 +349,12 @@ struct url : url_base {
349349
*/
350350
[[nodiscard]] inline bool cannot_have_credentials_or_port() const;
351351

352-
ada_really_inline size_t
353-
parse_port(std::string_view view,
354-
bool check_trailing_content = false) noexcept override;
352+
ada_really_inline size_t parse_port(
353+
std::string_view view, bool check_trailing_content) noexcept override;
354+
355+
ada_really_inline size_t parse_port(std::string_view view) noexcept override {
356+
return this->parse_port(view, false);
357+
}
355358

356359
/**
357360
* Take the scheme from another URL. The scheme string is copied from the
@@ -370,8 +373,7 @@ struct url : url_base {
370373
[[nodiscard]] ada_really_inline bool parse_host(std::string_view input);
371374

372375
template <bool has_state_override = false>
373-
[[nodiscard]] ada_really_inline bool parse_scheme(
374-
const std::string_view input);
376+
[[nodiscard]] ada_really_inline bool parse_scheme(std::string_view input);
375377

376378
inline void clear_pathname() override;
377379
inline void clear_search() override;
@@ -387,7 +389,7 @@ struct url : url_base {
387389
*
388390
* @see https://url.spec.whatwg.org/
389391
*/
390-
ada_really_inline void parse_path(const std::string_view input);
392+
ada_really_inline void parse_path(std::string_view input);
391393

392394
/**
393395
* Set the scheme for this URL. The provided scheme should be a valid

include/ada/url_aggregator-inl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ inline void url_aggregator::update_base_hostname(const std::string_view input) {
152152
ADA_ASSERT_TRUE(validate());
153153
}
154154

155-
ada_really_inline uint32_t
155+
[[nodiscard]] ada_really_inline uint32_t
156156
url_aggregator::get_pathname_length() const noexcept {
157157
ada_log("url_aggregator::get_pathname_length");
158158
uint32_t ending_index = uint32_t(buffer.size());
@@ -587,7 +587,7 @@ inline void url_aggregator::clear_port() {
587587
ADA_ASSERT_TRUE(validate());
588588
}
589589

590-
inline uint32_t url_aggregator::retrieve_base_port() const {
590+
[[nodiscard]] inline uint32_t url_aggregator::retrieve_base_port() const {
591591
ada_log("url_aggregator::retrieve_base_port");
592592
return components.port;
593593
}
@@ -812,7 +812,7 @@ inline bool url_aggregator::has_port() const noexcept {
812812
return has_hostname() && components.pathname_start != components.host_end;
813813
}
814814

815-
inline bool url_aggregator::has_dash_dot() const noexcept {
815+
[[nodiscard]] inline bool url_aggregator::has_dash_dot() const noexcept {
816816
// If url's host is null, url does not have an opaque path, url's path's size
817817
// is greater than 1, and url's path[0] is the empty string, then append
818818
// U+002F (/) followed by U+002E (.) to output.
@@ -833,7 +833,8 @@ inline bool url_aggregator::has_dash_dot() const noexcept {
833833
components.pathname_start + 1 < buffer.size();
834834
}
835835

836-
inline std::string_view url_aggregator::get_href() const noexcept {
836+
[[nodiscard]] inline std::string_view url_aggregator::get_href()
837+
const noexcept {
837838
ada_log("url_aggregator::get_href");
838839
return buffer;
839840
}

0 commit comments

Comments
 (0)