aboutsummaryrefslogtreecommitdiff
path: root/lldb
diff options
context:
space:
mode:
authorBrad Smith <brad@comstyle.com>2023-12-05 02:50:21 -0500
committerGitHub <noreply@github.com>2023-12-05 02:50:21 -0500
commit5c70c181a359e651bc58f98a4654e32087abe417 (patch)
tree557ef8f6744344c431657dc5fbf90e296cf04c5d /lldb
parent8cfdd37088d662338ec85ac15721dddf3f6d8db6 (diff)
downloadllvm-5c70c181a359e651bc58f98a4654e32087abe417.zip
llvm-5c70c181a359e651bc58f98a4654e32087abe417.tar.gz
llvm-5c70c181a359e651bc58f98a4654e32087abe417.tar.bz2
[lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (#74396)
Also eliminate an unused variable while here.
Diffstat (limited to 'lldb')
-rw-r--r--lldb/source/Host/openbsd/HostInfoOpenBSD.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
index 43f22be..b30c7a8 100644
--- a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
+++ b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
@@ -20,19 +20,23 @@ using namespace lldb_private;
llvm::VersionTuple HostInfoOpenBSD::GetOSVersion() {
struct utsname un;
- ::memset(&un, 0, sizeof(utsname));
- if (uname(&un) < 0)
+ ::memset(&un, 0, sizeof(un));
+ if (::uname(&un) < 0)
return llvm::VersionTuple();
- unsigned major, minor;
- if (2 == sscanf(un.release, "%u.%u", &major, &minor))
+ uint32_t major, minor;
+ int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32, &major, &minor);
+ switch (status) {
+ case 1:
+ return llvm::VersionTuple(major);
+ case 2:
return llvm::VersionTuple(major, minor);
+ }
return llvm::VersionTuple();
}
std::optional<std::string> HostInfoOpenBSD::GetOSBuildString() {
int mib[2] = {CTL_KERN, KERN_OSREV};
- char osrev_str[12];
uint32_t osrev = 0;
size_t osrev_len = sizeof(osrev);