Skip to content

Commit 48cd855

Browse files
committed
fix: avoid conflict of errno with the global in <errno.h>
1 parent 4efcb0d commit 48cd855

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

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)