Fixes warnings thrown by cpplint.py (#154)

* Fixed cpplint.py [runtime/int] warnings

* Fixed cpplint.py [readability/casting] warnings

* Fixed cpplint.py [readability/namespace] warnings

* Fixed cpplint.py [readability/braces] warnings

* Fixed cpplint.py [whitespace/braces] warnings

* Fixed cpplint.py [runtime/explicit] warnings

* Fixed cpplint.py [runtime/printf] warnings

* Fixed cpplint.py [readability/inheritance] warnings

* Fixed cpplint.py [whitespace/tab] warnings

* Fixed cpplint.py [build/storage_class] warnings

* Fixed cpplint.py [readability/multiline_comment] warnings

* Fixed cpplint.py [whitespace/semicolon] warnings

* Fixed cpplint.py [readability/check] warnings

* Fixed cpplint.py [runtime/arrays] warnings

* Ran format.py
This commit is contained in:
Tyler Veness
2016-07-10 17:47:44 -07:00
committed by Peter Johnson
parent e44a6e227a
commit 0cb288ffba
141 changed files with 670 additions and 626 deletions

View File

@@ -7,7 +7,7 @@
#include "AnalogGyro.h"
#include <cstdio>
#include <sstream>
#include "LiveWindow/LiveWindow.h"
#include "Timer.h"
@@ -32,9 +32,9 @@ const float AnalogGyro::kDefaultVoltsPerDegreePerSecond = 0.007;
void AnalogGyro::InitAnalogGyro(int channel) {
SetPIDSourceType(PIDSourceType::kDisplacement);
char buffer[50];
int n = std::sprintf(buffer, "analog/%d", channel);
impl = new SimGyro(buffer);
std::stringstream ss;
ss << "analog/" << channel;
impl = new SimGyro(ss.str());
LiveWindow::GetInstance()->AddSensor("AnalogGyro", channel, this);
}

View File

@@ -7,7 +7,7 @@
#include "AnalogInput.h"
#include <cstdio>
#include <sstream>
#include "LiveWindow/LiveWindow.h"
#include "WPIErrors.h"
@@ -17,11 +17,10 @@
*
* @param channel The channel number to represent.
*/
AnalogInput::AnalogInput(uint32_t channel) {
m_channel = channel;
char buffer[50];
int n = std::sprintf(buffer, "analog/%d", channel);
m_impl = new SimFloatInput(buffer);
AnalogInput::AnalogInput(uint32_t channel) : m_channel(channel) {
std::stringstream ss;
ss << "analog/" << channel;
m_impl = new SimFloatInput(ss.str());
LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
}

View File

@@ -7,7 +7,7 @@
#include "DigitalInput.h"
#include <cstdio>
#include <sstream>
#include "WPIErrors.h"
@@ -17,11 +17,10 @@
*
* @param channel The digital channel (1..14).
*/
DigitalInput::DigitalInput(uint32_t channel) {
char buf[64];
m_channel = channel;
int n = std::sprintf(buf, "dio/%d", channel);
m_impl = new SimDigitalInput(buf);
DigitalInput::DigitalInput(uint32_t channel) : m_channel(channel) {
std::stringstream ss;
ss << "dio/" << channel;
m_impl = new SimDigitalInput(ss.str());
}
/**

View File

@@ -35,10 +35,10 @@ DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
forwardChannel = channel;
m_reversed = true;
}
char buffer[50];
int n = std::sprintf(buffer, "pneumatic/%d/%d/%d/%d", moduleNumber,
forwardChannel, moduleNumber, reverseChannel);
m_impl = new SimContinuousOutput(buffer);
std::stringstream ss;
ss << "pneumatic/" << moduleNumber << "/" << forwardChannel << "/"
<< moduleNumber << "/" << reverseChannel;
m_impl = new SimContinuousOutput(ss.str());
LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", moduleNumber,
forwardChannel, this);

View File

@@ -128,13 +128,13 @@ bool DriverStation::GetStickButton(uint32_t stick, uint32_t button) {
* @param stick The joystick to read.
* @return The state of the buttons on the joystick.
*/
short DriverStation::GetStickButtons(uint32_t stick) {
int16_t DriverStation::GetStickButtons(uint32_t stick) {
if (stick < 0 || stick >= 6) {
wpi_setWPIErrorWithContext(ParameterOutOfRange,
"stick must be between 0 and 5");
return false;
}
short btns = 0, btnid;
int16_t btns = 0, btnid;
std::unique_lock<std::recursive_mutex> lock(m_joystickMutex);
msgs::FRCJoystickPtr joy = joysticks[stick];
@@ -147,7 +147,7 @@ short DriverStation::GetStickButtons(uint32_t stick) {
}
// 5V divided by 10 bits
#define kDSAnalogInScaling ((float)(5.0 / 1023.0))
#define kDSAnalogInScaling (static_cast<float>(5.0 / 1023.0))
/**
* Get an analog voltage from the Driver Station.

View File

@@ -7,7 +7,7 @@
#include "Encoder.h"
#include <cstdio>
#include <sstream>
#include "LiveWindow/LiveWindow.h"
#include "Resource.h"
@@ -51,9 +51,9 @@ void Encoder::InitEncoder(int32_t channelA, int32_t channelB,
} else {
m_reverseDirection = reverseDirection;
}
char buffer[50];
int n = std::sprintf(buffer, "dio/%d/%d", channelA, channelB);
impl = new SimEncoder(buffer);
std::stringstream ss;
ss << "dio/" << channelA << "/" << channelB;
impl = new SimEncoder(ss.str());
impl->Start();
}

View File

@@ -82,8 +82,9 @@ void Notifier::UpdateAlarm() {}
*/
void Notifier::ProcessQueue(uint32_t mask, void* params) {
Notifier* current;
while (true) // keep processing past events until no more
{
// keep processing events until no more
while (true) {
{
std::lock_guard<priority_recursive_mutex> sync(queueMutex);
double currentTime = GetClock();

View File

@@ -7,6 +7,8 @@
#include "PWM.h"
#include <sstream>
#include "Utility.h"
#include "WPIErrors.h"
@@ -26,16 +28,16 @@ const int32_t PWM::kPwmDisabled = 0;
* port
*/
PWM::PWM(uint32_t channel) {
char buf[64];
std::stringstream ss;
if (!CheckPWMChannel(channel)) {
std::snprintf(buf, 64, "PWM Channel %d", channel);
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
ss << "PWM Channel " << channel;
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, ss.str());
return;
}
std::sprintf(buf, "pwm/%d", channel);
impl = new SimContinuousOutput(buf);
ss << "pwm/" << channel;
impl = new SimContinuousOutput(ss.str());
m_channel = channel;
m_eliminateDeadband = false;
@@ -189,7 +191,7 @@ float PWM::GetSpeed() const {
*
* @param value Raw PWM value.
*/
void PWM::SetRaw(unsigned short value) {
void PWM::SetRaw(uint16_t value) {
wpi_assert(value == kPwmDisabled);
impl->Set(0);
}

View File

@@ -7,6 +7,8 @@
#include "Relay.h"
#include <sstream>
#include "LiveWindow/LiveWindow.h"
#include "MotorSafetyHelper.h"
#include "WPIErrors.h"
@@ -22,21 +24,21 @@
*/
Relay::Relay(uint32_t channel, Relay::Direction direction)
: m_channel(channel), m_direction(direction) {
char buf[64];
std::stringstream ss;
if (!SensorBase::CheckRelayChannel(m_channel)) {
std::snprintf(buf, 64, "Relay Channel %d", m_channel);
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
ss << "Relay Channel " << m_channel;
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, ss.str());
return;
}
m_safetyHelper = std::make_unique<MotorSafetyHelper>(this);
m_safetyHelper->SetSafetyEnabled(false);
std::sprintf(buf, "relay/%d", m_channel);
impl = new SimContinuousOutput(buf); // TODO: Allow two different relays
// (targetting the different halves of a
// relay) to be combined to control one
// motor.
ss << "relay/" << m_channel;
impl = new SimContinuousOutput(ss.str()); // TODO: Allow two different relays
// (targetting the different halves
// of a relay) to be combined to
// control one motor.
LiveWindow::GetInstance()->AddActuator("Relay", 1, m_channel, this);
go_pos = go_neg = false;
}

View File

@@ -7,7 +7,7 @@
#include "Solenoid.h"
#include <cstdio>
#include <sstream>
#include "LiveWindow/LiveWindow.h"
#include "WPIErrors.h"
@@ -27,9 +27,9 @@ Solenoid::Solenoid(uint32_t channel) : Solenoid(1, channel) {}
* @param channel The channel on the solenoid module to control (1..8).
*/
Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel) {
char buffer[50];
int n = std::sprintf(buffer, "pneumatic/%d/%d", moduleNumber, channel);
m_impl = new SimContinuousOutput(buffer);
std::stringstream ss;
ss << "pneumatic/" << moduleNumber << "/" << channel;
m_impl = new SimContinuousOutput(ss.str());
LiveWindow::GetInstance()->AddActuator("Solenoid", moduleNumber, channel,
this);

View File

@@ -24,7 +24,7 @@ void time_callback(const msgs::ConstFloat64Ptr& msg) {
time_wait.notify_all();
}
}
}
} // namespace wpilib
/**
* Pause the task for a specified time.

View File

@@ -40,8 +40,8 @@ void wpi_suspendOnAssertEnabled(bool enabled) {
static void wpi_handleTracing() {
// if (stackTraceEnabled)
// {
// std::printf("\n-----------<Stack Trace>----------------\n");
// printCurrentStackTrace();
// std::printf("\n-----------<Stack Trace>----------------\n");
// printCurrentStackTrace();
// }
std::printf("\n");
}