[Lldb-commits] [lldb] 5c70c18 - [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (#74396)

via lldb-commits lldb-commits at lists.llvm.org
Mon Dec 4 23:50:24 PST 2023


Author: Brad Smith
Date: 2023-12-05T02:50:21-05:00
New Revision: 5c70c181a359e651bc58f98a4654e32087abe417

URL: https://github.com/llvm/llvm-project/commit/5c70c181a359e651bc58f98a4654e32087abe417
DIFF: https://github.com/llvm/llvm-project/commit/5c70c181a359e651bc58f98a4654e32087abe417.diff

LOG: [lldb] Sync OpenBSD GetOSVersion() closer to NetBSD function (#74396)

Also eliminate an unused variable while here.

Added: 
    

Modified: 
    lldb/source/Host/openbsd/HostInfoOpenBSD.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp b/lldb/source/Host/openbsd/HostInfoOpenBSD.cpp
index 43f22be51ef95..b30c7a83243c0 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);
 


        


More information about the lldb-commits mailing list