Skip to content

Commit e1173a6

Browse files
authored
Merge pull request #54 from SpringQL/fix/avoid-errno
fix: avoid conflict of `errno` with the global in <errno.h>
2 parents 4efcb0d + bf5e2e6 commit e1173a6

File tree

8 files changed

+25
-18
lines changed

8 files changed

+25
-18
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ Also check the changes in springql-core: <https://github.com/SpringQL/SpringQL/b
1313
<!-- markdownlint-disable MD024 -->
1414
## [Unreleased]
1515

16+
## [v0.15.0+2] - 2022-06-30
17+
18+
### Fixed
19+
20+
- Fix name conflict of `errno` in a `spring_last_err`'s argument with `errno.h` ([#54](https://github.com/SpringQL/SpringQL-client-c/pull/54))
21+
1622
## [v0.15.0] - 2022-06-29
1723

1824
### Added
@@ -102,8 +108,9 @@ Depends on springql-core v0.7.1.
102108
[Semantic Versioning]: https://semver.org/
103109

104110
<!-- Versions -->
105-
[Unreleased]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.15.0...HEAD
111+
[Unreleased]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.15.0+2...HEAD
106112
[Released]: https://github.com/SpringQL/SpringQL-client-c/releases
113+
[v0.15.0+2]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.15.0...v0.15.0+2
107114
[v0.15.0]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.14.0...v0.15.0
108115
[v0.14.0]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.13.0+4...v0.14.0
109116
[v0.13.0+4]: https://github.com/SpringQL/SpringQL-client-c/compare/v0.13.0+3...v0.13.0+4

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "springql-client-c"
3-
version = "0.15.0"
3+
version = "0.15.0+2"
44

55
authors = ["Sho Nakatani <[email protected]>"]
66
license = "MIT OR Apache-2.0"

c_example/doc_app1/doc_app1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313

1414
void abort_with_report()
1515
{
16-
SpringErrno errno;
16+
SpringErrno errno_;
1717
char errmsg[1024];
18-
spring_last_err(&errno, errmsg, 1024);
19-
fprintf(stderr, "Error occurred (%d): %s", errno, errmsg);
18+
spring_last_err(&errno_, errmsg, 1024);
19+
fprintf(stderr, "Error occurred (%d): %s", errno_, errmsg);
2020
abort();
2121
}
2222

c_example/doc_app2/doc_app2.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
void abort_with_report()
2121
{
22-
SpringErrno errno;
22+
SpringErrno errno_;
2323
char errmsg[1024];
24-
spring_last_err(&errno, errmsg, 1024);
25-
fprintf(stderr, "Error occurred (%d): %s", errno, errmsg);
24+
spring_last_err(&errno_, errmsg, 1024);
25+
fprintf(stderr, "Error occurred (%d): %s", errno_, errmsg);
2626
abort();
2727
}
2828

c_example/trade_projection/trade_projection.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
void abort_with_report()
1414
{
15-
SpringErrno errno;
15+
SpringErrno errno_;
1616
char errmsg[1024];
17-
spring_last_err(&errno, errmsg, 1024);
18-
fprintf(stderr, "Error occurred (%d): %s", errno, errmsg);
17+
spring_last_err(&errno_, errmsg, 1024);
18+
fprintf(stderr, "Error occurred (%d): %s", errno_, errmsg);
1919
abort();
2020
}
2121

springql.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ enum SpringErrno spring_column_bool(const SpringSinkRow *row, uint16_t i_col, bo
415415
enum SpringErrno spring_column_float(const SpringSinkRow *row, uint16_t i_col, float *out);
416416

417417
/**
418-
* Write the most recent error number into `errno` and message into a caller-provided buffer as a UTF-8
418+
* Write the most recent error number into `errno_` and message into a caller-provided buffer as a UTF-8
419419
* string, returning the number of bytes written.
420420
*
421421
* # Note
@@ -433,7 +433,7 @@ enum SpringErrno spring_column_float(const SpringSinkRow *row, uint16_t i_col, f
433433
* - `> 0`: the length of the recent error message.
434434
* - `< 0`: SpringErrno
435435
*/
436-
int spring_last_err(enum SpringErrno *errno,
436+
int spring_last_err(enum SpringErrno *errno_,
437437
char *errmsg,
438438
int errmsg_len);
439439

src/spring_last_err.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ pub(super) fn update_last_error(err: LastError) {
7272
});
7373
}
7474

75-
/// Write the most recent error number into `errno` and message into a caller-provided buffer as a UTF-8
75+
/// Write the most recent error number into `errno_` and message into a caller-provided buffer as a UTF-8
7676
/// string, returning the number of bytes written.
7777
///
7878
/// # Note
@@ -91,7 +91,7 @@ pub(super) fn update_last_error(err: LastError) {
9191
/// - `< 0`: SpringErrno
9292
#[no_mangle]
9393
pub unsafe extern "C" fn spring_last_err(
94-
errno: *mut SpringErrno,
94+
errno_: *mut SpringErrno,
9595
errmsg: *mut c_char,
9696
errmsg_len: c_int,
9797
) -> c_int {
@@ -103,12 +103,12 @@ pub unsafe extern "C" fn spring_last_err(
103103
let last_error = match take_last_error() {
104104
Some(err) => err,
105105
None => {
106-
*errno = SpringErrno::Ok;
106+
*errno_ = SpringErrno::Ok;
107107
return SpringErrno::Ok as c_int;
108108
}
109109
};
110110

111-
*errno = SpringErrno::from(&last_error);
111+
*errno_ = SpringErrno::from(&last_error);
112112
let error_message = last_error.to_string();
113113

114114
strcpy(&error_message, errmsg, errmsg_len)

0 commit comments

Comments
 (0)