Skip to content

Commit

Permalink
Merge pull request #1028 from slaclab/linter-fix
Browse files Browse the repository at this point in the history
cpplint v2 - linter fix
  • Loading branch information
bengineerd authored Nov 4, 2024
2 parents 0cd3112 + 6842425 commit bd5f1f2
Show file tree
Hide file tree
Showing 51 changed files with 166 additions and 113 deletions.
17 changes: 9 additions & 8 deletions include/rogue/hardware/drivers/DmaDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,18 @@ struct DmaRegisterData {

// Conditional inclusion for non-kernel environments
#ifndef DMA_IN_KERNEL
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/fcntl.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/signal.h>
#include <sys/socket.h>
#include <unistd.h>

#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <cstring>

/**
* dmaWrite - Writes data to a DMA channel.
* @fd: File descriptor for the DMA device.
Expand All @@ -167,7 +168,7 @@ static inline ssize_t dmaWrite(int32_t fd, const void* buf, size_t size, uint32_
w.flags = flags;
w.size = size;
w.is32 = (sizeof(void*) == 4);
w.data = (uint64_t)buf;
w.data = (uint64_t)buf; // NOLINT

return (write(fd, &w, sizeof(struct DmaWriteData)));
}
Expand Down Expand Up @@ -237,7 +238,7 @@ static inline ssize_t dmaWriteVector(int32_t fd,
w.flags = (x == 0) ? begFlags : ((x == (iovlen - 1)) ? endFlags : midFlags);
w.size = iov[x].iov_len;
w.is32 = (sizeof(void*) == 4);
w.data = (uint64_t)iov[x].iov_base;
w.data = (uint64_t)iov[x].iov_base; // NOLINT

do {
res = write(fd, &w, sizeof(struct DmaWriteData));
Expand Down Expand Up @@ -288,7 +289,7 @@ static inline ssize_t dmaWriteIndexVector(int32_t fd,
w.flags = (x == 0) ? begFlags : ((x == (iovlen - 1)) ? endFlags : midFlags);
w.size = iov[x].iov_len;
w.is32 = (sizeof(void*) == 4);
w.index = (uint32_t)(((uint64_t)iov[x].iov_base) & 0xFFFFFFFF);
w.index = (uint32_t)(((uint64_t)iov[x].iov_base) & 0xFFFFFFFF); // NOLINT

do {
res = write(fd, &w, sizeof(struct DmaWriteData));
Expand Down Expand Up @@ -324,7 +325,7 @@ static inline ssize_t dmaRead(int32_t fd, void* buf, size_t maxSize, uint32_t* f
memset(&r, 0, sizeof(struct DmaReadData));
r.size = maxSize;
r.is32 = (sizeof(void*) == 4);
r.data = (uint64_t)buf;
r.data = (uint64_t)buf; // NOLINT

ret = read(fd, &r, sizeof(struct DmaReadData));

Expand Down
2 changes: 1 addition & 1 deletion include/rogue/interfaces/stream/Master.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
#include "rogue/Directives.h"

#include <stdint.h>
#include <stdio.h>

#include <cstdio>
#include <memory>
#include <mutex>
#include <string>
Expand Down
6 changes: 3 additions & 3 deletions include/rogue/protocols/xilinx/JtagDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

#include "rogue/Directives.h"

#include <errno.h>
#include <inttypes.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include <cerrno>
#include <cstdio>
#include <cstring>
#include <exception>
#include <memory>
#include <stdexcept>
Expand Down
1 change: 1 addition & 0 deletions src/package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "rogue/Directives.h"

#include <boost/python.hpp>
#include <cstdio>

#include "rogue/Version.h"
#include "rogue/module.h"
Expand Down
3 changes: 3 additions & 0 deletions src/rogue/GeneralError.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

#include <stdarg.h>

#include <cstdio>
#include <string>

#ifndef NO_PYTHON
#include <boost/python.hpp>
namespace bp = boost::python;
Expand Down
7 changes: 5 additions & 2 deletions src/rogue/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@

#include <inttypes.h>
#include <stdarg.h>
#include <string.h>
#include <sys/time.h>
#include <unistd.h>

#include <cstdio>
#include <cstring>
#include <memory>
#include <string>
#include <vector>

#if defined(__linux__)
#include <sys/syscall.h>
Expand Down Expand Up @@ -156,7 +159,7 @@ void rogue::Logging::logThreadId() {
#elif defined(__APPLE__) && defined(__MACH__)
uint64_t tid64;
pthread_threadid_np(NULL, &tid64);
tid = (uint32_t)tid64;
tid = static_cast<uint32_t>(tid64);
#else
tid = 0;
#endif
Expand Down
1 change: 1 addition & 0 deletions src/rogue/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <inttypes.h>
#include <unistd.h>

#include <cstdio>
#include <sstream>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion src/rogue/hardware/MemMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@

#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <cstdio>
#include <cstring>
#include <memory>
#include <thread>
Expand Down
3 changes: 2 additions & 1 deletion src/rogue/hardware/axi/AxiMemMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

#include <fcntl.h>
#include <inttypes.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>

#include <cstdio>
#include <cstring>
#include <memory>
#include <string>
#include <thread>

#include "rogue/GeneralError.h"
Expand Down
5 changes: 4 additions & 1 deletion src/rogue/hardware/axi/AxiStreamDma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
#include "rogue/hardware/axi/AxiStreamDma.h"

#include <inttypes.h>
#include <stdlib.h>

#include <cstdio>
#include <cstdlib>
#include <map>
#include <memory>
#include <string>

#include "rogue/GeneralError.h"
#include "rogue/GilRelease.h"
Expand Down
1 change: 1 addition & 0 deletions src/rogue/interfaces/ZmqClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <inttypes.h>
#include <zmq.h>

#include <cstdio>
#include <memory>
#include <string>

Expand Down
1 change: 1 addition & 0 deletions src/rogue/interfaces/api/Bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "rogue/interfaces/api/Bsp.h"

#include <boost/make_shared.hpp>
#include <memory>
#include <string>

#include "rogue/GeneralError.h"
Expand Down
39 changes: 22 additions & 17 deletions src/rogue/interfaces/memory/Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
#include "rogue/interfaces/memory/Block.h"

#include <inttypes.h>
#include <string.h>
#include <sys/time.h>

#include <cmath>
#include <cstdio>
#include <cstring>
#include <exception>
#include <iomanip>
#include <memory>
#include <sstream>
#include <string>
#include <vector>

#include "rogue/GeneralError.h"
#include "rogue/GilRelease.h"
Expand Down Expand Up @@ -195,12 +198,12 @@ void rim::Block::intStartTransaction(uint32_t type, bool forceWr, bool check, ri
} else {
if (type == rim::Read || type == rim::Verify) {
if (index < 0 || index >= var->numValues_) {
lowByte = var->lowTranByte_[0];
lowByte = var->lowTranByte_[0];

if ( var->numValues_ == 0 ) {
if (var->numValues_ == 0) {
highByte = var->highTranByte_[0];
} else {
highByte = var->highTranByte_[var->numValues_-1];
highByte = var->highTranByte_[var->numValues_ - 1];
}
} else {
lowByte = var->lowTranByte_[index];
Expand Down Expand Up @@ -511,14 +514,14 @@ void rim::Block::addVariables(std::vector<rim::VariablePtr> variables) {
(*vit)->verifyEn_);
}

// List variables
// List variables
} else {
for (x = 0; x < (*vit)->numValues_; x++) {
// Variable allows overlaps, add to overlap enable mask
if ((*vit)->overlapEn_) {
setBits(oleMask, x * (*vit)->valueStride_ + (*vit)->bitOffset_[0], (*vit)->valueBits_);

// Otherwise add to exclusive mask and check for existing mapping
// Otherwise add to exclusive mask and check for existing mapping
} else {
if (anyBits(excMask, x * (*vit)->valueStride_ + (*vit)->bitOffset_[0], (*vit)->valueBits_))
throw(rogue::GeneralError::create(
Expand Down Expand Up @@ -572,7 +575,7 @@ void rim::Block::addVariables(std::vector<rim::VariablePtr> variables) {
x = 0;

while (rem > 0) {
ss << "0x" << std::setfill('0') << std::hex << std::setw(2) << (uint32_t)(verifyMask_[x]) << " ";
ss << "0x" << std::setfill('0') << std::hex << std::setw(2) << static_cast<uint32_t>(verifyMask_[x]) << " ";
x++;
rem--;
if (rem == 0 || x % 10 == 0) {
Expand Down Expand Up @@ -1010,7 +1013,7 @@ bp::object rim::Block::getUIntPy(rim::Variable* var, int32_t index) {
PyArrayObject* arr = reinterpret_cast<PyArrayObject*>(obj);
uint32_t* dst = reinterpret_cast<uint32_t*>(PyArray_DATA(arr));

for (x = 0; x < var->numValues_; x++) dst[x] = (uint32_t)getUInt(var, x);
for (x = 0; x < var->numValues_; x++) dst[x] = static_cast<uint32_t>(getUInt(var, x));
}
boost::python::handle<> handle(obj);
ret = bp::object(handle);
Expand Down Expand Up @@ -1086,13 +1089,13 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index)
var->name_.c_str()));

if (PyArray_TYPE(arr) == NPY_INT64) {
int64_t* src = reinterpret_cast<int64_t*>(PyArray_DATA(arr));
int64_t* src = reinterpret_cast<int64_t*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(int64_t);
for (x = 0; x < dims[0]; x++) {
setInt(src[x * stride], var, index + x);
}
} else if (PyArray_TYPE(arr) == NPY_INT32) {
int32_t* src = reinterpret_cast<int32_t*>(PyArray_DATA(arr));
int32_t* src = reinterpret_cast<int32_t*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(int32_t);
for (x = 0; x < dims[0]; x++) {
setInt(src[x * stride], var, index + x);
Expand Down Expand Up @@ -1175,7 +1178,7 @@ bp::object rim::Block::getIntPy(rim::Variable* var, int32_t index) {
PyArrayObject* arr = reinterpret_cast<PyArrayObject*>(obj);
int32_t* dst = reinterpret_cast<int32_t*>(PyArray_DATA(arr));

for (x = 0; x < var->numValues_; x++) dst[x] = (int32_t)getInt(var, x);
for (x = 0; x < var->numValues_; x++) dst[x] = static_cast<int32_t>(getInt(var, x));
}
boost::python::handle<> handle(obj);
ret = bp::object(handle);
Expand Down Expand Up @@ -1214,7 +1217,9 @@ int64_t rim::Block::getInt(rim::Variable* var, int32_t index) {
getBytes(reinterpret_cast<uint8_t*>(&tmp), var, index);

if (var->valueBits_ != 64) {
if (tmp >= (uint64_t)pow(2, var->valueBits_ - 1)) tmp -= (uint64_t)pow(2, var->valueBits_);
if (tmp >= static_cast<uint64_t>(pow(2, var->valueBits_ - 1))) {
tmp -= static_cast<uint64_t>(pow(2, var->valueBits_));
}
}
return tmp;
}
Expand Down Expand Up @@ -1255,7 +1260,7 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index)
var->name_.c_str()));

if (PyArray_TYPE(arr) == NPY_BOOL) {
bool* src = reinterpret_cast<bool*>(PyArray_DATA(arr));
bool* src = reinterpret_cast<bool*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(bool);
for (x = 0; x < dims[0]; x++) {
setBool(src[x * stride], var, index + x);
Expand Down Expand Up @@ -1467,7 +1472,7 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index
var->name_.c_str()));

if (PyArray_TYPE(arr) == NPY_FLOAT32) {
float* src = reinterpret_cast<float*>(PyArray_DATA(arr));
float* src = reinterpret_cast<float*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(float);
for (x = 0; x < dims[0]; x++) {
setFloat(src[x * stride], var, index + x);
Expand Down Expand Up @@ -1616,7 +1621,7 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde
var->name_.c_str()));

if (PyArray_TYPE(arr) == NPY_FLOAT64) {
double* src = reinterpret_cast<double*>(PyArray_DATA(arr));
double* src = reinterpret_cast<double*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(double);
for (x = 0; x < dims[0]; x++) {
setDouble(src[x * stride], var, index + x);
Expand Down Expand Up @@ -1765,7 +1770,7 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index
var->name_.c_str()));

if (PyArray_TYPE(arr) == NPY_FLOAT64) {
double* src = reinterpret_cast<double*>(PyArray_DATA(arr));
double* src = reinterpret_cast<double*>(PyArray_DATA(arr));
npy_intp stride = strides[0] / sizeof(double);
for (x = 0; x < dims[0]; x++) {
setFixed(src[x * stride], var, index + x);
Expand Down Expand Up @@ -1867,7 +1872,7 @@ void rim::Block::setFixed(const double& val, rim::Variable* var, int32_t index)
var->maxValue_));

// Convert
int64_t fPoint = (int64_t)round(val * pow(2, var->binPoint_));
int64_t fPoint = static_cast<int64_t>(round(val * pow(2, var->binPoint_)));
// Check for positive edge case
uint64_t mask = 1 << (var->valueBits_ - 1);
if (val > 0 && ((fPoint & mask) != 0)) {
Expand Down
4 changes: 3 additions & 1 deletion src/rogue/interfaces/memory/Emulate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
#include "rogue/interfaces/memory/Emulate.h"

#include <inttypes.h>
#include <string.h>

#include <cstring>
#include <memory>
#include <string>
#include <utility>

#include "rogue/GilRelease.h"
#include "rogue/interfaces/memory/Constants.h"
Expand Down
1 change: 1 addition & 0 deletions src/rogue/interfaces/memory/Hub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include <cmath>
#include <memory>
#include <string>

#include "rogue/GilRelease.h"
#include "rogue/ScopedGil.h"
Expand Down
3 changes: 2 additions & 1 deletion src/rogue/interfaces/memory/Master.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
#include "rogue/interfaces/memory/Master.h"

#include <inttypes.h>
#include <stdlib.h>

#include <cstdlib>
#include <cstring>
#include <memory>
#include <string>

#include "rogue/GeneralError.h"
#include "rogue/GilRelease.h"
Expand Down
1 change: 1 addition & 0 deletions src/rogue/interfaces/memory/Slave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "rogue/interfaces/memory/Slave.h"

#include <memory>
#include <string>

#include "rogue/GeneralError.h"
#include "rogue/GilRelease.h"
Expand Down
Loading

0 comments on commit bd5f1f2

Please sign in to comment.