Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build on alpha and x32 architectures #634

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/raft/uv_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,18 @@ static int probeDirectIO(int fd, size_t *size, char *errmsg)
default:
/* UNTESTED: this is an unsupported file system.
*/
#if defined(__s390x__)
#if defined(__alpha__)
ErrMsgPrintf(errmsg,
"unsupported file system: %x",
fs_info.f_type);
#elif defined(__s390x__)
ErrMsgPrintf(errmsg,
"unsupported file system: %ux",
fs_info.f_type);
#elif defined(__x86_64__) && defined(__ILP32__)
ErrMsgPrintf(errmsg,
"unsupported file system: %llx",
fs_info.f_type);
#else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this part be fixed by casting fs_info.f_type to a sufficiently wide type instead? Would prefer to avoid the ifdefs if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From statfs(2):

The __fsword_t type used for various fields in the statfs structure definition is a glibc internal type, not intended for public use. This leaves the programmer in a bit of a conundrum when trying to copy or compare these fields to local variables in a program. Using unsigned int for such variables suffices on most systems.

Casting to an unsigned int or unsigned long should work; I copied the ifdefs since there was already one there for s390x.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I hadn't noticed the existing ifdef -- we should remove that too! (No need to do it in this PR.) Casting to unsigned long would be my preferred approach here.

ErrMsgPrintf(errmsg,
"unsupported file system: %zx",
Expand Down
2 changes: 1 addition & 1 deletion src/raft/uv_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
if (f.f_bsize == 0) {
increment = 512;
} else if (f.f_bsize < 4096) {
increment = f.f_bsize;
increment = (ssize_t)f.f_bsize;

Check warning on line 55 in src/raft/uv_os.c

View check run for this annotation

Codecov / codecov/patch

src/raft/uv_os.c#L55

Added line #L55 was not covered by tests
} else {
increment = 4096;
}
Expand Down
2 changes: 1 addition & 1 deletion src/tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static inline void tracerEmit(const char *file,
tracerPidCached,

tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour,
tm.tm_min, tm.tm_sec, ts.tv_nsec,
gibmat marked this conversation as resolved.
Show resolved Hide resolved
tm.tm_min, tm.tm_sec, (unsigned long)ts.tv_nsec,

(unsigned)tid, tracerTraceLevelName(level), func,
tracerShortFileName(file), line, message);
Expand Down
Loading