Skip to content

Commit bf64e1f

Browse files
committed
Refactor noexcept_call usage for improved consistency across headers
- Updated calls to `noexcept_call` in various headers to remove the scope resolution operator (::) for system functions, enhancing readability and consistency. - Improved error handling by ensuring all system function calls are wrapped with `noexcept_call` for safer error management. - This change aligns with recent refactoring efforts to standardize function call patterns throughout the codebase.
1 parent 199701b commit bf64e1f

File tree

48 files changed

+298
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+298
-298
lines changed

include/fast_io_core_impl/allocation/c_malloc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace details
1616
inline ::std::size_t c_malloc_usable_size_impl(void *p) noexcept
1717
{
1818
#if defined(_WIN32) && !defined(__WINE__) && !defined(__CYGWIN__)
19-
return ::fast_io::noexcept_call(::_msize, p);
19+
return ::fast_io::noexcept_call(_msize, p);
2020
#else
2121
return ::malloc_usable_size(p);
2222
#endif
@@ -139,7 +139,7 @@ class c_malloc_allocator
139139
}
140140
else
141141
{
142-
p = ::fast_io::noexcept_call(::_aligned_malloc, n, alignment);
142+
p = ::fast_io::noexcept_call(_aligned_malloc, n, alignment);
143143
}
144144
if (p == nullptr)
145145
{
@@ -169,7 +169,7 @@ class c_malloc_allocator
169169
}
170170
else
171171
{
172-
p = ::fast_io::noexcept_call(::_aligned_realloc, p, n, alignment);
172+
p = ::fast_io::noexcept_call(_aligned_realloc, p, n, alignment);
173173
}
174174
if (p == nullptr)
175175
{
@@ -194,7 +194,7 @@ class c_malloc_allocator
194194
}
195195
else
196196
{
197-
::fast_io::noexcept_call(::_aligned_free, p);
197+
::fast_io::noexcept_call(_aligned_free, p);
198198
}
199199
}
200200
#endif

include/fast_io_core_impl/allocation/wincrt_malloc_dbg.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class wincrt_malloc_dbg_allocator
1717
{
1818
n = 1;
1919
}
20-
void *p = ::fast_io::noexcept_call(::_malloc_dbg, n, 1, __FILE__, __LINE__);
20+
void *p = ::fast_io::noexcept_call(_malloc_dbg, n, 1, __FILE__, __LINE__);
2121
if (p == nullptr)
2222
{
2323
::fast_io::fast_terminate();
@@ -33,7 +33,7 @@ class wincrt_malloc_dbg_allocator
3333
{
3434
n = 1;
3535
}
36-
p = ::fast_io::noexcept_call(::_realloc_dbg, p, n, 1, __FILE__, __LINE__);
36+
p = ::fast_io::noexcept_call(_realloc_dbg, p, n, 1, __FILE__, __LINE__);
3737
if (p == nullptr)
3838
{
3939
::fast_io::fast_terminate();
@@ -49,7 +49,7 @@ class wincrt_malloc_dbg_allocator
4949
{
5050
n = 1;
5151
}
52-
void *p = ::fast_io::noexcept_call(::_calloc_dbg, 1, n, 1, __FILE__, __LINE__);
52+
void *p = ::fast_io::noexcept_call(_calloc_dbg, 1, n, 1, __FILE__, __LINE__);
5353
if (p == nullptr)
5454
{
5555
::fast_io::fast_terminate();
@@ -62,24 +62,24 @@ class wincrt_malloc_dbg_allocator
6262
{
6363
return;
6464
}
65-
::fast_io::noexcept_call(::_free_dbg, p, 1);
65+
::fast_io::noexcept_call(_free_dbg, p, 1);
6666
}
6767

6868
#if 0
6969
static inline allocation_least_result allocate_at_least(::std::size_t n) noexcept
7070
{
7171
auto p{::fast_io::wincrt_malloc_dbg_allocator::allocate(n)};
72-
return {p, ::fast_io::noexcept_call(::_msize_dbg, p, 1)};
72+
return {p, ::fast_io::noexcept_call(_msize_dbg, p, 1)};
7373
}
7474
static inline allocation_least_result allocate_zero_at_least(::std::size_t n) noexcept
7575
{
7676
auto p{::fast_io::wincrt_malloc_dbg_allocator::allocate_zero(n)};
77-
return {p, ::fast_io::noexcept_call(::_msize_dbg, p, 1)};
77+
return {p, ::fast_io::noexcept_call(_msize_dbg, p, 1)};
7878
}
7979
static inline allocation_least_result reallocate_at_least(void *oldp, ::std::size_t n) noexcept
8080
{
8181
auto p{::fast_io::wincrt_malloc_dbg_allocator::reallocate(oldp, n)};
82-
return {p, ::fast_io::noexcept_call(::_msize_dbg, p, 1)};
82+
return {p, ::fast_io::noexcept_call(_msize_dbg, p, 1)};
8383
}
8484
#endif
8585
};

include/fast_io_crypto/platforms/ossl_evp.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class ossl_evp_guard
1111
public:
1212
EVP_MD_CTX *pmdctx{};
1313
inline ossl_evp_guard()
14-
: pmdctx{noexcept_call(::EVP_MD_CTX_new)}
14+
: pmdctx{noexcept_call(EVP_MD_CTX_new)}
1515
{
1616
if (this->pmdctx == nullptr)
1717
{
@@ -30,20 +30,20 @@ class ossl_evp_guard
3030
{
3131
if (this->pmdctx)
3232
{
33-
noexcept_call(::EVP_MD_CTX_free, this->pmdctx);
33+
noexcept_call(EVP_MD_CTX_free, this->pmdctx);
3434
}
3535
}
3636
};
3737

3838
inline EVP_MD_CTX *create_ossl_evp_hash_impl(char const *name)
3939
{
40-
auto md{noexcept_call(::EVP_get_digestbyname, name)};
40+
auto md{noexcept_call(EVP_get_digestbyname, name)};
4141
if (md == nullptr)
4242
{
4343
throw_posix_error(EINVAL);
4444
}
4545
ossl_evp_guard guard;
46-
if (!noexcept_call(::EVP_DigestInit_ex, guard.pmdctx, md, nullptr))
46+
if (!noexcept_call(EVP_DigestInit_ex, guard.pmdctx, md, nullptr))
4747
{
4848
throw_posix_error(EINVAL);
4949
}
@@ -86,19 +86,19 @@ class ossl_evp_hash_file
8686
{
8787
if (this->pmdctx)
8888
{
89-
noexcept_call(::EVP_MD_CTX_free, this->pmdctx);
89+
noexcept_call(EVP_MD_CTX_free, this->pmdctx);
9090
}
9191
}
9292
inline void update(::std::byte const *first, ::std::byte const *last)
9393
{
94-
if (!noexcept_call(::EVP_DigestUpdate, this->pmdctx, first, static_cast<::std::size_t>(last - first)))
94+
if (!noexcept_call(EVP_DigestUpdate, this->pmdctx, first, static_cast<::std::size_t>(last - first)))
9595
{
9696
throw_posix_error(EINVAL);
9797
}
9898
}
9999
inline void reset()
100100
{
101-
noexcept_call(::EVP_MD_CTX_reset, this->pmdctx);
101+
noexcept_call(EVP_MD_CTX_reset, this->pmdctx);
102102
}
103103
inline constexpr native_handle_type native_handle() const noexcept
104104
{
@@ -107,7 +107,7 @@ class ossl_evp_hash_file
107107
inline void do_final()
108108
{
109109
int unsigned u{};
110-
if (!noexcept_call(::EVP_DigestFinal_ex, this->pmdctx, reinterpret_cast<char unsigned *>(digest_buffer),
110+
if (!noexcept_call(EVP_DigestFinal_ex, this->pmdctx, reinterpret_cast<char unsigned *>(digest_buffer),
111111
__builtin_addressof(u)))
112112
{
113113
throw_posix_error(EINVAL);

include/fast_io_driver/avformat/avio.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ inline void write(basic_avio_context_io_observer<char_type> baciob, char_type co
4848
{
4949
this_round = diff;
5050
}
51-
::fast_io::noexcept_call(::avio_write, baciob.avios, first, last);
51+
::fast_io::noexcept_call(avio_write, baciob.avios, first, last);
5252
first += this_round;
5353
}
5454
}
5555
else
5656
{
57-
::fast_io::noexcept_call(::avio_write, baciob.avios, first, static_cast<int>(last - first));
57+
::fast_io::noexcept_call(avio_write, baciob.avios, first, static_cast<int>(last - first));
5858
}
5959
if (baciob.avios->error)
6060
{
@@ -79,11 +79,11 @@ inline char_type *read(basic_avio_context_io_observer<char_type> baciob, char_ty
7979
{
8080
this_round = diff;
8181
}
82-
ret = ::fast_io::noexcept_call(::avio_read, baciob.avios, first, this_round);
82+
ret = ::fast_io::noexcept_call(avio_read, baciob.avios, first, this_round);
8383
}
8484
else
8585
{
86-
ret = ::fast_io::noexcept_call(::avio_read, baciob.avios, first, static_cast<int>(last - first));
86+
ret = ::fast_io::noexcept_call(avio_read, baciob.avios, first, static_cast<int>(last - first));
8787
}
8888
if (baciob.avios->error)
8989
{
@@ -165,7 +165,7 @@ class basic_avio_context_file : public basic_avio_context_io_observer<ch_type>
165165
{
166166
return;
167167
}
168-
fast_io::noexcept_call(::av_free, this->avios);
168+
fast_io::noexcept_call(av_free, this->avios);
169169
this->avios = nullptr;
170170
}
171171
basic_avio_context_file(basic_avio_context_file const &) = delete;
@@ -201,7 +201,7 @@ struct avio_buffer
201201
{
202202
return;
203203
}
204-
::fast_io::noexcept_call(::av_free, buffer);
204+
::fast_io::noexcept_call(av_free, buffer);
205205
this->buffer = nullptr;
206206
}
207207
avio_buffer(avio_buffer const &) = delete;
@@ -249,7 +249,7 @@ inline basic_avio_buffer_context<typename rftype::char_type> create_avio_context
249249
{
250250
using char_type = typename rftype::char_type;
251251
constexpr int buffersize{16384};
252-
auto bfptr{::fast_io::noexcept_call(::av_malloc, buffersize)};
252+
auto bfptr{::fast_io::noexcept_call(av_malloc, buffersize)};
253253
if (bfptr == nullptr)
254254
{
255255
::fast_io::fast_terminate();
@@ -381,7 +381,7 @@ struct avformat_context_guard
381381
{
382382
return;
383383
}
384-
::fast_io::noexcept_call(::avformat_free_context, pFormatCtx);
384+
::fast_io::noexcept_call(avformat_free_context, pFormatCtx);
385385
this->pFormatCtx = nullptr;
386386
}
387387

@@ -415,7 +415,7 @@ struct avformat_input_guard
415415
{
416416
return;
417417
}
418-
::fast_io::noexcept_call(::avformat_close_input, ppFormatCtx);
418+
::fast_io::noexcept_call(avformat_close_input, ppFormatCtx);
419419
this->ppFormatCtx = nullptr;
420420
}
421421

include/fast_io_driver/capstone.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace details
2828

2929
inline void cs_option_wrapper_impl(::std::size_t csh, cs_opt_type t, ::std::size_t value)
3030
{
31-
auto ret{::fast_io::noexcept_call(::cs_option, csh, t, value)};
31+
auto ret{::fast_io::noexcept_call(cs_option, csh, t, value)};
3232
if (ret != CS_ERR_OK)
3333
{
3434
throw_cs_error(ret);
@@ -68,15 +68,15 @@ class cs_file : public cs_io_observer
6868
{
6969
if (this->csh) [[likely]]
7070
{
71-
::fast_io::noexcept_call(::cs_close, __builtin_addressof(this->csh));
71+
::fast_io::noexcept_call(cs_close, __builtin_addressof(this->csh));
7272
}
7373
this->csh = c.csh;
7474
c.csh = 0;
7575
return *this;
7676
}
7777
cs_file(cs_arch arch, cs_mode mode)
7878
{
79-
auto ret{::fast_io::noexcept_call(::cs_open, arch, mode, __builtin_addressof(this->csh))};
79+
auto ret{::fast_io::noexcept_call(cs_open, arch, mode, __builtin_addressof(this->csh))};
8080
if (ret != CS_ERR_OK)
8181
{
8282
throw_cs_error(ret);
@@ -86,7 +86,7 @@ class cs_file : public cs_io_observer
8686
{
8787
if (this->csh) [[likely]]
8888
{
89-
::fast_io::noexcept_call(::cs_close, __builtin_addressof(this->csh));
89+
::fast_io::noexcept_call(cs_close, __builtin_addressof(this->csh));
9090
}
9191
}
9292
};
@@ -114,7 +114,7 @@ class cs_insn_range
114114
explicit cs_insn_range(cs_io_observer csiob, char const *buffer, ::std::size_t code_size,
115115
::std::uint_least64_t address, ::std::size_t c) noexcept
116116
{
117-
count = noexcept_call(::cs_disasm, csiob.csh, reinterpret_cast<::std::uint_least8_t const *>(buffer), code_size,
117+
count = noexcept_call(cs_disasm, csiob.csh, reinterpret_cast<::std::uint_least8_t const *>(buffer), code_size,
118118
address, c, __builtin_addressof(ins));
119119
}
120120
cs_insn_range(cs_insn_range const &) = delete;
@@ -129,7 +129,7 @@ class cs_insn_range
129129
{
130130
if (this->ins) [[likely]]
131131
{
132-
::fast_io::noexcept_call(::cs_free, this->ins, this->count);
132+
::fast_io::noexcept_call(cs_free, this->ins, this->count);
133133
}
134134
this->ins = other.ins;
135135
this->count = other.count;
@@ -141,7 +141,7 @@ class cs_insn_range
141141
{
142142
if (this->ins) [[likely]]
143143
{
144-
::fast_io::noexcept_call(::cs_free, this->ins, this->count);
144+
::fast_io::noexcept_call(cs_free, this->ins, this->count);
145145
}
146146
}
147147
constexpr pointer data() const noexcept

include/fast_io_driver/install_path/argv0.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ inline ::fast_io::install_path get_module_install_path_from_argv0(char const *ar
3636
char path_list_separator[8] = ":"; // could be ":; "
3737
if (argv0[0] == path_separator)
3838
{
39-
[[maybe_unused]] auto const unused1{::fast_io::noexcept_call(::realpath, argv0, newpath)};
40-
if (auto status{::fast_io::noexcept_call(::access, newpath, F_OK)}; !status)
39+
[[maybe_unused]] auto const unused1{::fast_io::noexcept_call(realpath, argv0, newpath)};
40+
if (auto status{::fast_io::noexcept_call(access, newpath, F_OK)}; !status)
4141
{
4242
newpath[PATH_MAX - 1] = 0;
4343
ret.module_name = ::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt_os_c_str(newpath));
@@ -62,11 +62,11 @@ inline ::fast_io::install_path get_module_install_path_from_argv0(char const *ar
6262
}
6363
else if (__builtin_strchr(argv0, static_cast<int>(path_separator)))
6464
{
65-
[[maybe_unused]] auto const unused1{::fast_io::noexcept_call(::getcwd, newpath2, PATH_MAX)};
66-
::fast_io::noexcept_call(::strncat, newpath2, path_separator_as_string, PATH_MAX + 256);
67-
::fast_io::noexcept_call(::strncat, newpath2, argv0, PATH_MAX + 256);
68-
[[maybe_unused]] auto const unused2{::fast_io::noexcept_call(::realpath, newpath2, newpath)};
69-
if (auto status{::fast_io::noexcept_call(::access, newpath, F_OK)}; !status)
65+
[[maybe_unused]] auto const unused1{::fast_io::noexcept_call(getcwd, newpath2, PATH_MAX)};
66+
::fast_io::noexcept_call(strncat, newpath2, path_separator_as_string, PATH_MAX + 256);
67+
::fast_io::noexcept_call(strncat, newpath2, argv0, PATH_MAX + 256);
68+
[[maybe_unused]] auto const unused2{::fast_io::noexcept_call(realpath, newpath2, newpath)};
69+
if (auto status{::fast_io::noexcept_call(access, newpath, F_OK)}; !status)
7070
{
7171
newpath[PATH_MAX - 1] = 0;
7272
ret.module_name = ::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt_os_c_str(newpath));
@@ -93,22 +93,22 @@ inline ::fast_io::install_path get_module_install_path_from_argv0(char const *ar
9393
{
9494
char *saveptr{};
9595
char *pathitem{};
96-
char const *env_path{::fast_io::noexcept_call(::getenv, "PATH")};
96+
char const *env_path{::fast_io::noexcept_call(getenv, "PATH")};
9797
if (!env_path) [[unlikely]]
9898
{
9999
throw_posix_error(EINVAL);
100100
}
101101
char pathbuf[PATH_MAX + 256 + 1]{};
102-
::fast_io::noexcept_call(::strncpy, pathbuf, env_path, PATH_MAX + 256);
102+
::fast_io::noexcept_call(strncpy, pathbuf, env_path, PATH_MAX + 256);
103103

104-
for (pathitem = ::fast_io::noexcept_call(::strtok_r, pathbuf, path_list_separator, &saveptr); pathitem;
105-
pathitem = ::fast_io::noexcept_call(::strtok_r, nullptr, path_list_separator, &saveptr))
104+
for (pathitem = ::fast_io::noexcept_call(strtok_r, pathbuf, path_list_separator, &saveptr); pathitem;
105+
pathitem = ::fast_io::noexcept_call(strtok_r, nullptr, path_list_separator, &saveptr))
106106
{
107-
::fast_io::noexcept_call(::strncpy, newpath2, pathitem, PATH_MAX + 256);
108-
::fast_io::noexcept_call(::strncat, newpath2, path_separator_as_string, PATH_MAX + 256);
109-
::fast_io::noexcept_call(::strncat, newpath2, argv0, PATH_MAX + 256);
107+
::fast_io::noexcept_call(strncpy, newpath2, pathitem, PATH_MAX + 256);
108+
::fast_io::noexcept_call(strncat, newpath2, path_separator_as_string, PATH_MAX + 256);
109+
::fast_io::noexcept_call(strncat, newpath2, argv0, PATH_MAX + 256);
110110
[[maybe_unused]] auto const unused1{::realpath(newpath2, newpath)};
111-
if (!::fast_io::noexcept_call(::access, newpath, F_OK))
111+
if (!::fast_io::noexcept_call(access, newpath, F_OK))
112112
{
113113
newpath[PATH_MAX - 1] = 0;
114114
ret.module_name = ::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt_os_c_str(newpath));

include/fast_io_driver/install_path/bsd.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ inline ::fast_io::install_path get_module_install_path()
3636
#endif
3737
::std::size_t size{PATH_MAX};
3838

39-
if (auto status{::fast_io::noexcept_call(::sysctl, mib, 4, buffer1, __builtin_addressof(size), nullptr, 0)}; !status) [[unlikely]]
39+
if (auto status{::fast_io::noexcept_call(sysctl, mib, 4, buffer1, __builtin_addressof(size), nullptr, 0)}; !status) [[unlikely]]
4040
{
4141
throw_posix_error();
4242
}
4343

44-
resolved = ::fast_io::noexcept_call(::realpath, buffer1, buffer2);
44+
resolved = ::fast_io::noexcept_call(realpath, buffer1, buffer2);
4545

4646
if (!resolved) [[unlikely]]
4747
{

include/fast_io_driver/install_path/darwin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ inline ::fast_io::install_path get_module_install_path()
2828
{
2929
char buffer[PATH_MAX + 1];
3030
::std::uint_least32_t size{PATH_MAX};
31-
if (::fast_io::noexcept_call(::_NSGetExecutablePath, buffer, __builtin_addressof(size)) == -1) [[unlikely]]
31+
if (::fast_io::noexcept_call(_NSGetExecutablePath, buffer, __builtin_addressof(size)) == -1) [[unlikely]]
3232
{
3333
if (size > PATH_MAX)
3434
{
@@ -40,7 +40,7 @@ inline ::fast_io::install_path get_module_install_path()
4040
}
4141
}
4242
char buffer2[PATH_MAX + 1];
43-
char *resolved{::fast_io::noexcept_call(::realpath, buffer, buffer2)};
43+
char *resolved{::fast_io::noexcept_call(realpath, buffer, buffer2)};
4444
if (!resolved) [[unlikely]]
4545
{
4646
throw_posix_error();

include/fast_io_driver/install_path/linux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ inline ::fast_io::install_path get_module_install_path()
3030
ret.module_name = ::fast_io::u8concat_fast_io(::fast_io::mnp::code_cvt(::fast_io::mnp::os_c_str_with_known_size(buffer, resolved)));
3131
#else
3232
char *resolved{
33-
::fast_io::noexcept_call(::realpath,
33+
::fast_io::noexcept_call(realpath,
3434
#if defined(__sun)
3535
"/proc/self/path/a.out"
3636
#else

0 commit comments

Comments
 (0)