[CDRIVER-4674] Pointless code in bson-clock.c Created: 06/Jul/23 Updated: 28/Oct/23 Resolved: 20/Jul/23 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | BSON |
| Affects Version/s: | 1.24.1 |
| Fix Version/s: | 1.24.3 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Ryan Schmidt | Assignee: | Josh Siegel (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
SummaryThese lines in bson-clock.c are pointless and can be removed: The code essentially says if clock_gettime and CLOCK_MONOTONIC are defined, use them, otherwise if we're on macOS, use clock_gettime_nsec_np and CLOCK_UPTIME_RAW. This makes no sense since clock_gettime and CLOCK_MONOTONIC were introduced in OS X 10.11 and clock_gettime_nsec_np and CLOCK_UPTIME_RAW were introduced in macOS 10.12. So what happens on OS X 10.11 and later is that the first block of code that uses clock_gettime gets used and this compiles fine. And on OS X 10.10 and earlier the second block that uses clock_gettime_nsec_np is used which fails to compile. Environmentlibbson 1.24.1 OS X 10.10 (or earlier) x86_64 (but this is irrelevant) Apple LLVM version 7.0.2 (clang-700.1.81) (but this is irrelevant) How to ReproduceBuild libbson 1.24.1 (with the patch to fix Additional BackgroundThe previous version of the don't-have-clock_gettime fallback code for macOS compiled fine because it used mach_timebase_info and mach_absolute_time which exist on every version of macOS. Now that this code was removed, the headers for the mach time functions can be removed too: |
| Comments |
| Comment by Githook User [ 28/Jul/23 ] |
|
Author: {'name': 'Joshua Siegel', 'email': '39130209+joshbsiegel@users.noreply.github.com', 'username': 'joshbsiegel'}Message: |
| Comment by Githook User [ 20/Jul/23 ] |
|
Author: {'name': 'Joshua Siegel', 'email': '39130209+joshbsiegel@users.noreply.github.com', 'username': 'joshbsiegel'}Message: |
| Comment by Githook User [ 20/Jul/23 ] |
|
Author: {'name': 'Joshua Siegel', 'email': '39130209+joshbsiegel@users.noreply.github.com', 'username': 'joshbsiegel'}Message: |
| Comment by PM Bot [ 06/Jul/23 ] |
|
Hi ryandesign, thank you for reporting this issue! The team will look into it and get back to you soon. |