Skip to content

Commit

Permalink
Upgrade to clang-format 8 (#2268)
Browse files Browse the repository at this point in the history
* Update to clang-format 8

* Revise installer to use clang-format-8

* Update documentation
  • Loading branch information
mikee47 authored Mar 26, 2021
1 parent 0d77c34 commit 54231b9
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 32 deletions.
15 changes: 8 additions & 7 deletions Sming/Core/Network/NtpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ void NtpClient::requestTime()
}

ip_addr_t resolvedIp;
int result = dns_gethostbyname(server.c_str(), &resolvedIp,
[](const char* name, LWIP_IP_ADDR_T* ip, void* arg) {
// We do a new request since the last one was never done.
if(ip)
reinterpret_cast<NtpClient*>(arg)->internalRequestTime(*ip);
},
this);
int result = dns_gethostbyname(
server.c_str(), &resolvedIp,
[](const char* name, LWIP_IP_ADDR_T* ip, void* arg) {
// We do a new request since the last one was never done.
if(ip)
reinterpret_cast<NtpClient*>(arg)->internalRequestTime(*ip);
},
this);

debug_d("dns_gethostbyname() returned %d", result);

Expand Down
19 changes: 10 additions & 9 deletions Sming/Core/Network/TcpConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,16 @@ bool TcpConnection::connect(const String& server, int port, bool useSsl)
int port;
};
DnsLookup* look = new DnsLookup{this, port};
err_t dnslook = dns_gethostbyname(server.c_str(), &addr,
[](const char* name, LWIP_IP_ADDR_T* ipaddr, void* arg) {
auto dlook = static_cast<DnsLookup*>(arg);
if(dlook != nullptr) {
dlook->con->internalOnDnsResponse(name, ipaddr, dlook->port);
delete dlook;
}
},
look);
err_t dnslook = dns_gethostbyname(
server.c_str(), &addr,
[](const char* name, LWIP_IP_ADDR_T* ipaddr, void* arg) {
auto dlook = static_cast<DnsLookup*>(arg);
if(dlook != nullptr) {
dlook->con->internalOnDnsResponse(name, ipaddr, dlook->port);
delete dlook;
}
},
look);
if(dnslook == ERR_INPROGRESS) {
// Operation pending - see internalOnDnsResponse()
return true;
Expand Down
17 changes: 9 additions & 8 deletions Sming/Core/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,15 @@ class Task
switch(state) {
case State::Suspended:
case State::Running:
sleepTimer.initializeMs(interval,
[](void* param) {
auto task = static_cast<Task*>(param);
task->notify(Notify::Waking);
task->state = State::Running;
task->service();
},
this);
sleepTimer.initializeMs(
interval,
[](void* param) {
auto task = static_cast<Task*>(param);
task->notify(Notify::Waking);
task->state = State::Running;
task->service();
},
this);
sleepTimer.startOnce();
notify(Notify::Sleeping);
state = State::Sleeping;
Expand Down
6 changes: 3 additions & 3 deletions Tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if [ -n "$APPVEYOR" ] || [ -n "$GITHUB_ACTION" ]; then

sudo apt-get -y update
$PKG_INSTALL \
clang-format-6.0 \
clang-format-8 \
g++-9-multilib \
python3-setuptools

Expand All @@ -105,7 +105,7 @@ else
debian)
sudo apt-get -y update
$PKG_INSTALL \
clang-format-6.0 \
clang-format-8 \
cmake \
curl \
git \
Expand Down Expand Up @@ -143,7 +143,7 @@ else

fi

sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-6.0 100
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-8 100

python3 -m pip install --upgrade pip -r $SMING_HOME/../Tools/requirements.txt

Expand Down
17 changes: 12 additions & 5 deletions docs/source/information/develop/clang-tools.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Clang Tools
===========

`clang-format <https://releases.llvm.org/6.0.0/tools/clang/docs/ClangFormat.html>`__
`clang-format <https://releases.llvm.org/8.0.1/tools/clang/docs/ClangFormat.html>`__
is a tool that implements automatic source code formatting.
It can be used to automatically enforce the layout rules for Sming.

`clang-tidy <https://releases.llvm.org/6.0.0/tools/clang/tools/extra/docs/clang-tidy/index.html>`__
`clang-tidy <https://releases.llvm.org/8.0.1/tools/clang/tools/extra/docs/clang-tidy/index.html>`__
is a C++ “linter” tool to assist with diagnosing and fixing typical programming errors
such as style violations, interface misuse, or bugs that can be deduced via static analysis.
It is provided as part of
Expand All @@ -26,9 +26,16 @@ See the the `download <http://releases.llvm.org/download.html>`__ page
of the Clang project for installation instructions for other operating
systems.

We are using version 6.0 of clang-format and clang-tidy on our
Continuous Integration (CI) System. You should install the same
version or newer on your development computer.
.. important::

Different versions of clang-format can produce different results,
despite using the same configuration file.

We are using version 8.0.1 of clang-format and clang-tidy on our
Continuous Integration (CI) System.

You should install the same version on your development computer.



Configuration
Expand Down

0 comments on commit 54231b9

Please sign in to comment.