[libc-commits] [libc] a439c4a - [libc][Obvious] Address few GCC warnings.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Mon Jan 9 12:54:51 PST 2023
Author: Siva Chandra Reddy
Date: 2023-01-09T20:54:13Z
New Revision: a439c4afdc4f6e24f8cbed0aa10820e2fe48317c
URL: https://github.com/llvm/llvm-project/commit/a439c4afdc4f6e24f8cbed0aa10820e2fe48317c
DIFF: https://github.com/llvm/llvm-project/commit/a439c4afdc4f6e24f8cbed0aa10820e2fe48317c.diff
LOG: [libc][Obvious] Address few GCC warnings.
Added:
Modified:
libc/src/__support/arg_list.h
libc/src/__support/float_to_string.h
libc/src/math/generic/log10.cpp
libc/src/stdio/printf_core/converter_utils.h
libc/src/stdio/stderr.cpp
libc/src/stdio/stdin.cpp
libc/src/stdio/stdout.cpp
libc/src/unistd/environ.cpp
libc/src/unistd/getopt.cpp
libc/startup/linux/x86_64/start.cpp
Removed:
################################################################################
diff --git a/libc/src/__support/arg_list.h b/libc/src/__support/arg_list.h
index 3a885df6495ea..4d82b5e5b2aee 100644
--- a/libc/src/__support/arg_list.h
+++ b/libc/src/__support/arg_list.h
@@ -22,6 +22,11 @@ class ArgList {
ArgList(ArgList &other) { va_copy(this->vlist, other.vlist); }
~ArgList() { va_end(this->vlist); }
+ ArgList &operator=(ArgList &rhs) {
+ va_copy(vlist, rhs.vlist);
+ return *this;
+ }
+
template <class T> T inline next_var() { return va_arg(vlist, T); }
};
diff --git a/libc/src/__support/float_to_string.h b/libc/src/__support/float_to_string.h
index da1defa7646a3..b7b1d38070ab2 100644
--- a/libc/src/__support/float_to_string.h
+++ b/libc/src/__support/float_to_string.h
@@ -359,8 +359,8 @@ constexpr size_t FloatToString<long double>::zero_blocks_after_point() {
}
template <>
-constexpr bool FloatToString<long double>::is_lowest_block(size_t block_index) {
- return block_index < 0;
+constexpr bool FloatToString<long double>::is_lowest_block(size_t) {
+ return false;
}
template <>
diff --git a/libc/src/math/generic/log10.cpp b/libc/src/math/generic/log10.cpp
index 3ce634baf89e3..dbc9f80448c27 100644
--- a/libc/src/math/generic/log10.cpp
+++ b/libc/src/math/generic/log10.cpp
@@ -914,13 +914,11 @@ double log10_accurate(int e_x, int index, double m_x) {
fputil::DoubleDouble mx{/*lo*/ 0.0, /*hi*/ m_x};
// Further range reductions.
- int idx[R_STEPS];
double scale = 0x1.0p+7;
const fputil::DyadicFloat<128> NEG_ONE(-1.0);
for (size_t i = 0; i < R_STEPS; ++i) {
scale *= 0x1.0p+4;
int id = static_cast<int>(fputil::multiply_add(mx.hi, scale, 0x1.0p+4));
- idx[i] = id;
double r = RR[i][id];
fputil::DoubleDouble rm = fputil::exact_mult(r, mx.hi);
rm.hi += r - 1.0;
diff --git a/libc/src/stdio/printf_core/converter_utils.h b/libc/src/stdio/printf_core/converter_utils.h
index ec605abf7deb8..4d2c84700ad37 100644
--- a/libc/src/stdio/printf_core/converter_utils.h
+++ b/libc/src/stdio/printf_core/converter_utils.h
@@ -41,6 +41,7 @@ inline uintmax_t apply_length_modifier(uintmax_t num, LengthModifier lm) {
case LengthModifier::j:
return num; // j is intmax, so no mask is necessary.
}
+ __builtin_unreachable();
}
#define RET_IF_RESULT_NEGATIVE(func) \
diff --git a/libc/src/stdio/stderr.cpp b/libc/src/stdio/stderr.cpp
index e3ceae94aa242..56ec9b78a67f0 100644
--- a/libc/src/stdio/stderr.cpp
+++ b/libc/src/stdio/stderr.cpp
@@ -10,4 +10,6 @@
#include <stdio.h>
-extern "C" FILE *stderr = reinterpret_cast<FILE *>(__llvm_libc::stderr);
+extern "C" {
+FILE *stderr = reinterpret_cast<FILE *>(__llvm_libc::stderr);
+}
diff --git a/libc/src/stdio/stdin.cpp b/libc/src/stdio/stdin.cpp
index cd34189c4b115..b6ae95d32ff40 100644
--- a/libc/src/stdio/stdin.cpp
+++ b/libc/src/stdio/stdin.cpp
@@ -10,4 +10,6 @@
#include <stdio.h>
-extern "C" FILE *stdin = reinterpret_cast<FILE *>(__llvm_libc::stdin);
+extern "C" {
+FILE *stdin = reinterpret_cast<FILE *>(__llvm_libc::stdin);
+}
diff --git a/libc/src/stdio/stdout.cpp b/libc/src/stdio/stdout.cpp
index c64275a0a952c..7eb9e1bf8e735 100644
--- a/libc/src/stdio/stdout.cpp
+++ b/libc/src/stdio/stdout.cpp
@@ -10,4 +10,6 @@
#include <stdio.h>
-extern "C" FILE *stdout = reinterpret_cast<FILE *>(__llvm_libc::stdout);
+extern "C" {
+FILE *stdout = reinterpret_cast<FILE *>(__llvm_libc::stdout);
+}
diff --git a/libc/src/unistd/environ.cpp b/libc/src/unistd/environ.cpp
index d3f6f4cca4712..2a554fd9fcb4c 100644
--- a/libc/src/unistd/environ.cpp
+++ b/libc/src/unistd/environ.cpp
@@ -9,6 +9,8 @@
namespace __llvm_libc {
// This is initialized to the correct value by the statup code.
-extern "C" char **environ = nullptr;
+extern "C" {
+char **environ = nullptr;
+}
} // namespace __llvm_libc
diff --git a/libc/src/unistd/getopt.cpp b/libc/src/unistd/getopt.cpp
index 9d3b53400560e..e68f906b3e270 100644
--- a/libc/src/unistd/getopt.cpp
+++ b/libc/src/unistd/getopt.cpp
@@ -170,10 +170,14 @@ int getopt_r(int argc, char *const argv[], const char *optstring,
namespace impl {
-extern "C" char *optarg = nullptr;
-extern "C" int optind = 1;
-extern "C" int optopt = 0;
-extern "C" int opterr = 0;
+extern "C" {
+
+char *optarg = nullptr;
+int optind = 1;
+int optopt = 0;
+int opterr = 0;
+
+}
static unsigned optpos;
diff --git a/libc/startup/linux/x86_64/start.cpp b/libc/startup/linux/x86_64/start.cpp
index 6ddb344b339af..15d5de59d42c1 100644
--- a/libc/startup/linux/x86_64/start.cpp
+++ b/libc/startup/linux/x86_64/start.cpp
@@ -151,8 +151,8 @@ extern "C" void _start() {
// compilers can generate code assuming the alignment as required by the ABI.
// If the stack pointers as setup by the OS are already aligned, then the
// following code is a NOP.
- __asm__ __volatile__("andq $0xfffffffffffffff0, %%rsp\n\t" ::: "%rsp");
- __asm__ __volatile__("andq $0xfffffffffffffff0, %%rbp\n\t" ::: "%rbp");
+ __asm__ __volatile__("andq $0xfffffffffffffff0, %rsp\n\t");
+ __asm__ __volatile__("andq $0xfffffffffffffff0, %rbp\n\t");
auto tid = __llvm_libc::syscall_impl(SYS_gettid);
if (tid <= 0)
More information about the libc-commits
mailing list