avoid more shadowing

This commit is contained in:
Matthew Kennedy 2023-11-01 15:52:30 -07:00
parent 8e846e8842
commit 71dc7b715e
9 changed files with 40 additions and 40 deletions

View File

@ -105,12 +105,12 @@ float GppwmChannel::setOutput(float result) {
}
}
void GppwmChannel::init(bool usePwm, IPwm* pwm, OutputPin* outputPin, const ValueProvider3D* table, const gppwm_channel* config) {
void GppwmChannel::init(bool usePwm, IPwm* pwm, OutputPin* outputPin, const ValueProvider3D* table, const gppwm_channel* cfg) {
m_usePwm = usePwm;
m_pwm = pwm;
m_output = outputPin;
m_table = table;
m_config = config;
m_config = cfg;
}
GppwmResult GppwmChannel::getOutput() const {

View File

@ -17,7 +17,7 @@ struct GppwmResult {
class GppwmChannel {
public:
void init(bool usePwm, IPwm* pwm, OutputPin* outputPin, const ValueProvider3D* table, const gppwm_channel* config);
void init(bool usePwm, IPwm* pwm, OutputPin* outputPin, const ValueProvider3D* table, const gppwm_channel* cfg);
GppwmResult update();
GppwmResult getOutput() const;

View File

@ -18,7 +18,7 @@ static vvt_map_t vvtTable1;
static vvt_map_t vvtTable2;
VvtController::VvtController(int index, int bankIndex, int camIndex)
: index(index)
: m_index(index)
, m_bank(bankIndex)
, m_cam(camIndex)
{
@ -65,7 +65,7 @@ expected<angle_t> VvtController::getSetpoint() {
}
#if EFI_TUNER_STUDIO
engine->outputChannels.vvtTargets[index] = target;
engine->outputChannels.vvtTargets[m_index] = target;
#endif
vvtTarget = target;
@ -105,7 +105,7 @@ expected<percent_t> VvtController::getClosedLoop(angle_t target, angle_t observa
float retVal = m_pid.getOutput(target, observation);
#if EFI_TUNER_STUDIO
m_pid.postState(engine->outputChannels.vvtStatus[index]);
m_pid.postState(engine->outputChannels.vvtStatus[m_index]);
#endif /* EFI_TUNER_STUDIO */
return retVal;

View File

@ -38,11 +38,11 @@ public:
void setOutput(expected<percent_t> outputValue) override;
private:
const int index = 0;
const int m_index;
// Bank index, 0 or 1
const uint8_t m_bank = 0;
const uint8_t m_bank;
// Cam index, 0 = intake, 1 = exhaust
const uint8_t m_cam = 0;
const uint8_t m_cam;
Pid m_pid;

View File

@ -223,8 +223,8 @@ int findEndOfToken(const char *line) {
int tokenLength(const char *msgp) {
int result = 0;
while (*msgp) {
char ch = *msgp++;
if (ch == SPACE_CHAR) {
char c = *msgp++;
if (c == SPACE_CHAR) {
break;
}
result++;

View File

@ -45,7 +45,7 @@
bool Logging::validateBuffer(uint32_t extraLen) {
if (remainingSize() < extraLen + 1) {
#if EFI_PROD_CODE
warning(ObdCode::CUSTOM_LOGGING_BUFFER_OVERFLOW, "output overflow %s %d", name, extraLen);
warning(ObdCode::CUSTOM_LOGGING_BUFFER_OVERFLOW, "output overflow %s %d", m_name, extraLen);
#endif /* EFI_PROD_CODE */
return true;
}
@ -60,21 +60,21 @@ void Logging::append(const char *text) {
if (isCapacityProblem) {
return;
}
strcpy(linePointer, text);
strcpy(m_linePointer, text);
/**
* And now we are pointing at the zero char at the end of the buffer again
*/
linePointer += extraLen;
m_linePointer += extraLen;
}
/**
* @note This method if fast because it does not validate much, be sure what you are doing
*/
void Logging::appendFast(const char *text) {
char *s = linePointer;
char *s = m_linePointer;
while ((*s++ = *text++) != 0)
;
linePointer = s - 1;
m_linePointer = s - 1;
}
void Logging::appendPrintf(const char *fmt, ...) {
@ -84,14 +84,14 @@ void Logging::appendPrintf(const char *fmt, ...) {
va_list ap;
va_start(ap, fmt);
size_t written = chvsnprintf(linePointer, available, fmt, ap);
size_t written = chvsnprintf(m_linePointer, available, fmt, ap);
va_end(ap);
// chvnsprintf returns how many bytes WOULD HAVE been written if it fit,
// so clip it to the available space if necessary
linePointer += (written > available) ? available : written;
m_linePointer += (written > available) ? available : written;
// ensure buffer is always null terminated
buffer[bufferSize - 1] = '\0';
m_buffer[m_bufferSize - 1] = '\0';
}
void Logging::appendFloat(float value, int precision) {
@ -126,17 +126,17 @@ void Logging::appendFloat(float value, int precision) {
}
void Logging::reset() {
linePointer = buffer;
*linePointer = 0;
m_linePointer = m_buffer;
*m_linePointer = 0;
}
Logging::Logging(char const *name, char *buffer, int bufferSize)
: name(name)
, buffer(buffer)
, bufferSize(bufferSize)
: m_name(name)
, m_buffer(buffer)
, m_bufferSize(bufferSize)
{
reset();
}
LoggingWithStorage::LoggingWithStorage(const char *name) : Logging(name, DEFAULT_BUFFER, sizeof(DEFAULT_BUFFER)) {
LoggingWithStorage::LoggingWithStorage(const char *name) : Logging(name, DEFAULT_BUFFER, sizeof(DEFAULT_BUFFER)) {
}

View File

@ -25,43 +25,43 @@ public:
void appendFloat(float value, int precision);
void terminate() {
linePointer[0] = '\0';
m_linePointer[0] = '\0';
}
/**
* This macro breaks the normal zero=termination constraint, please take care of this outside of this function
*/
void appendChar(char c) {
*linePointer = c;
linePointer++;
*m_linePointer = c;
m_linePointer++;
}
size_t loggingSize() const {
return (uintptr_t)linePointer - (uintptr_t)buffer;
return (uintptr_t)m_linePointer - (uintptr_t)m_buffer;
}
size_t remainingSize() const {
return bufferSize - loggingSize();
return m_bufferSize - loggingSize();
}
//private:
bool validateBuffer(uint32_t extraLen);
const char* const name = nullptr;
const char* const m_name;
/**
* Zero-terminated buffer of pending debug message
*
* Unless a larger external buffer is specified, this is just a pointer to DEFAULT_BUFFER
*/
char* const buffer = nullptr;
const int bufferSize = 0;
char* const m_buffer;
const int m_bufferSize;
/**
* This pointer is always pointing at the position within the buffer into which next
* write operation would append additional data
*/
char *linePointer = nullptr;
char* m_linePointer = nullptr;
};
class LoggingWithStorage : public Logging {

View File

@ -91,16 +91,16 @@ int atoi(const char *string) {
int result = 0;
for (int i = 0; i < len; i++) {
char ch = string[i];
if (ch < '0' || ch > '9') {
char c = string[i];
if (c < '0' || c > '9') {
if (i > 0) {
break;
} else {
return ATOI_ERROR_CODE;
}
}
int c = ch - '0';
result = result * 10 + c;
int num = c - '0';
result = result * 10 + num;
}
return result;

View File

@ -35,8 +35,8 @@ void LogBuffer<TBufferSize>::writeLine(LogLineBuffer* line) {
}
template <size_t TBufferSize>
void LogBuffer<TBufferSize>:: writeLogger(Logging* logging) {
writeInternal(logging->buffer);
void LogBuffer<TBufferSize>::writeLogger(Logging* logging) {
writeInternal(logging->m_buffer);
}
template <size_t TBufferSize>