universal7885: Fix clang-tidy issue again

This commit is contained in:
roynatech2544 2022-05-21 12:58:03 +00:00
commit 988595370b
9 changed files with 32 additions and 32 deletions

View file

@ -35,7 +35,6 @@ tidy_errors = [
"performance-move-constructor-init", "performance-move-constructor-init",
"performance-noexcept-move-constructor", "performance-noexcept-move-constructor",
"performance-unnecessary-copy-initialization", "performance-unnecessary-copy-initialization",
"performance-unnecessary-value-param",
"readability-avoid-const-params-in-decls", "readability-avoid-const-params-in-decls",
] ]

View file

@ -3,6 +3,7 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <fcntl.h> #include <fcntl.h>
#include <stdint.h>
#include <cstring> #include <cstring>
#include <unistd.h> #include <unistd.h>
#include <cerrno> #include <cerrno>
@ -25,18 +26,18 @@ using vendor::eureka::hardware::fmradio::V1_2::IFMRadio;
// #define DEBUG // #define DEBUG
#define TRACK_SIZE 30 #define TRACK_SIZE 30
long tracks[TRACK_SIZE] = {0}; int64_t tracks[TRACK_SIZE] = {0};
bool FMThread = false; bool FMThread = false;
int open_fm_device() { int open_fm_device() {
int fd; int fd;
if ((fd = open("/dev/radio0", O_RDWR)) < 0) { if ((fd = open("/dev/radio0", O_RDWR | O_CLOEXEC)) < 0) {
printf("Cannot open /dev/radio0.\n"); printf("Cannot open /dev/radio0.\n");
return -1; return -1;
} }
return fd; return fd;
} }
static int fm_radio_get_frequency(int fd, long *channel) { static int fm_radio_get_frequency(int fd, int64_t *channel) {
struct v4l2_frequency freq {}; struct v4l2_frequency freq {};
int ret; int ret;
@ -49,12 +50,12 @@ static int fm_radio_get_frequency(int fd, long *channel) {
return FM_FAILURE; return FM_FAILURE;
} }
*channel = (long)freq.frequency / 16000; *channel = (int64_t)freq.frequency / 16000;
return FM_SUCCESS; return FM_SUCCESS;
} }
static int fm_radio_set_frequency(int fd, long channel) { static int fm_radio_set_frequency(int fd, int64_t channel) {
struct v4l2_frequency freq {}; struct v4l2_frequency freq {};
int ret; int ret;
@ -71,7 +72,7 @@ static int fm_radio_set_frequency(int fd, long channel) {
return FM_SUCCESS; return FM_SUCCESS;
} }
static int fm_radio_set_control(int fd, unsigned int id, long val) { static int fm_radio_set_control(int fd, unsigned int id, int64_t val) {
struct v4l2_control ctrl {}; struct v4l2_control ctrl {};
int ret; int ret;
#ifdef DEBUG #ifdef DEBUG
@ -114,7 +115,7 @@ static int fm_radio_seek_frequency(int fd, unsigned int upward,
} }
static int fm_radio_channel_searching(int fd, unsigned int upward, static int fm_radio_channel_searching(int fd, unsigned int upward,
unsigned int wrap_around, unsigned int wrap_around,
unsigned int spacing, long *channel) { unsigned int spacing, int64_t *channel) {
int ret; int ret;
ret = fm_radio_set_control(fd, V4L2_CID_S610_SEEK_MODE, ret = fm_radio_set_control(fd, V4L2_CID_S610_SEEK_MODE,
@ -190,15 +191,15 @@ template <class C, typename T> bool contains(C &&c, T e) {
return std::find(std::begin(c), std::end(c), e) != std::end(c); return std::find(std::begin(c), std::end(c), e) != std::end(c);
} }
static long fm_radio_get_freqs(int fd) { static int64_t fm_radio_get_freqs(int fd) {
long ret = 0; int64_t ret = 0;
fm_radio_set_mute(fd, true); fm_radio_set_mute(fd, true);
sp<IFMRadio> service = IFMRadio::getService(); sp<IFMRadio> service = IFMRadio::getService();
bool mSysfs = service->isAvailable() == Status::YES; bool mSysfs = service->isAvailable() == Status::YES;
for (long &track : tracks) { for (int64_t &track : tracks) {
if (mSysfs) { if (mSysfs) {
service->adjustFreqByStep(Direction::UP); service->adjustFreqByStep(Direction::UP);
ret = (long)service->getFreqFromSysfs(); ret = (int64_t)service->getFreqFromSysfs();
} else { } else {
fm_radio_channel_searching(fd, 1, 0, FM_CHANNEL_SPACING_50KHZ, &ret); fm_radio_channel_searching(fd, 1, 0, FM_CHANNEL_SPACING_50KHZ, &ret);
} }
@ -298,10 +299,10 @@ static unsigned int fm_radio_get_lowerband_limit(int fd) {
return freq; return freq;
} }
} }
static long fm_radio_get_rmssi(int fd) { static int64_t fm_radio_get_rmssi(int fd) {
struct v4l2_tuner tuner {}; struct v4l2_tuner tuner {};
int ret; int ret;
long rmssi; int64_t rmssi;
tuner.index = 0; tuner.index = 0;
tuner.signal = 0; tuner.signal = 0;
ret = ioctl(fd, VIDIOC_G_TUNER, &tuner); ret = ioctl(fd, VIDIOC_G_TUNER, &tuner);
@ -313,7 +314,7 @@ static long fm_radio_get_rmssi(int fd) {
} }
return ret; return ret;
} }
static int fm_radio_set_rssi(int fd, long rssi) { static int fm_radio_set_rssi(int fd, int64_t rssi) {
int ret = fm_radio_set_control(fd, V4L2_CID_S610_RSSI_TH, rssi); int ret = fm_radio_set_control(fd, V4L2_CID_S610_RSSI_TH, rssi);
if (ret < 0) { if (ret < 0) {
return FM_FAILURE; return FM_FAILURE;
@ -329,7 +330,7 @@ extern "C" JNIEXPORT jlong JNICALL
Java_com_eurekateam_fmradio_NativeFMInterface_getFMFreq(__unused JNIEnv *env, Java_com_eurekateam_fmradio_NativeFMInterface_getFMFreq(__unused JNIEnv *env,
__unused jobject thiz, __unused jobject thiz,
jint fd) { jint fd) {
long freq; int64_t freq;
fm_radio_get_frequency(fd, &freq); fm_radio_get_frequency(fd, &freq);
return freq; return freq;
} }
@ -372,7 +373,7 @@ Java_com_eurekateam_fmradio_NativeFMInterface_getRMSSI(__unused JNIEnv *env,
return fm_radio_get_rmssi(fd); return fm_radio_get_rmssi(fd);
} }
extern "C" JNIEXPORT jlongArray JNICALL extern "C" JNIEXPORT jlongArray JNICALL
Java_com_eurekateam_fmradio_NativeFMInterface_getFMTracks(__unused JNIEnv *env, Java_com_eurekateam_fmradio_NativeFMInterface_getFMTracks(JNIEnv *env,
__unused jobject thiz, __unused jobject thiz,
jint fd) { jint fd) {
fm_radio_get_freqs(fd); fm_radio_get_freqs(fd);
@ -383,7 +384,7 @@ Java_com_eurekateam_fmradio_NativeFMInterface_getFMTracks(__unused JNIEnv *env,
} }
int i; int i;
// fill a temp structure to use to populate the java int array // fill a temp structure to use to populate the java int array
jlong fill[TRACK_SIZE]; int64_t fill[TRACK_SIZE];
for (i = 0; i < TRACK_SIZE; i++) { for (i = 0; i < TRACK_SIZE; i++) {
fill[i] = fill[i] =
tracks[i]; // put whatever logic you want to populate the values here. tracks[i]; // put whatever logic you want to populate the values here.
@ -437,7 +438,7 @@ Java_com_eurekateam_fmradio_NativeFMInterface_setFMBoot(__unused JNIEnv *env,
extern "C" JNIEXPORT jint JNICALL extern "C" JNIEXPORT jint JNICALL
Java_com_eurekateam_fmradio_NativeFMInterface_getNextChannel( Java_com_eurekateam_fmradio_NativeFMInterface_getNextChannel(
__unused JNIEnv *env, __unused jobject thiz, jint fd) { __unused JNIEnv *env, __unused jobject thiz, jint fd) {
long ret; int64_t ret;
sp<IFMRadio> service = IFMRadio::getService(); sp<IFMRadio> service = IFMRadio::getService();
bool mSysfs = service->isAvailable() == Status::YES; bool mSysfs = service->isAvailable() == Status::YES;
if (!mSysfs) { if (!mSysfs) {
@ -451,7 +452,7 @@ Java_com_eurekateam_fmradio_NativeFMInterface_getNextChannel(
extern "C" JNIEXPORT jint JNICALL extern "C" JNIEXPORT jint JNICALL
Java_com_eurekateam_fmradio_NativeFMInterface_getBeforeChannel( Java_com_eurekateam_fmradio_NativeFMInterface_getBeforeChannel(
__unused JNIEnv *env, __unused jobject thiz, jint fd) { __unused JNIEnv *env, __unused jobject thiz, jint fd) {
long ret; int64_t ret;
sp<IFMRadio> service = IFMRadio::getService(); sp<IFMRadio> service = IFMRadio::getService();
bool mSysfs = service->isAvailable() == Status::YES; bool mSysfs = service->isAvailable() == Status::YES;
if (!mSysfs) { if (!mSysfs) {
@ -481,7 +482,7 @@ Java_com_eurekateam_fmradio_NativeFMInterface_stopSearching(
extern "C" JNIEXPORT jint JNICALL extern "C" JNIEXPORT jint JNICALL
Java_com_eurekateam_fmradio_NativeFMInterface_setFMRSSI(__unused JNIEnv *env, Java_com_eurekateam_fmradio_NativeFMInterface_setFMRSSI(__unused JNIEnv *env,
__unused jobject thiz, __unused jobject thiz,
jint fd, jlong rssi) { jint fd, jint rssi) {
return fm_radio_set_rssi(fd, rssi); return fm_radio_set_rssi(fd, rssi);
} }
extern "C" JNIEXPORT void JNICALL extern "C" JNIEXPORT void JNICALL

View file

@ -17,7 +17,7 @@
#include <media/AudioSystem.h> #include <media/AudioSystem.h>
#include <media/IAudioFlinger.h> #include <media/IAudioFlinger.h>
#define FM_FAILURE -1 #define FM_FAILURE (-1)
#define FM_SUCCESS 0 #define FM_SUCCESS 0
#define IOHANDLE 13 #define IOHANDLE 13
using namespace android; using namespace android;

View file

@ -1,4 +1,4 @@
#define FM_FAILURE -1 #define FM_FAILURE (-1)
#define FM_SUCCESS 0 #define FM_SUCCESS 0
#define V4L2_CID_USER_S610_BASE (0x00980900 + 0x1070) #define V4L2_CID_USER_S610_BASE (0x00980900 + 0x1070)

View file

@ -95,7 +95,7 @@ struct v4l2_buffer {
__u32 memory; __u32 memory;
union { union {
__u32 offset; __u32 offset;
unsigned long userptr; uint64_t userptr;
struct v4l2_plane *planes; struct v4l2_plane *planes;
__s32 fd; __s32 fd;
} m; } m;

View file

@ -65,7 +65,7 @@ SamsungCameraProvider::SamsungCameraProvider()
} }
Return<void> SamsungCameraProvider::getCameraIdList( Return<void> SamsungCameraProvider::getCameraIdList(
ICameraProvider::getCameraIdList_cb _hidl_cb) { const ICameraProvider::getCameraIdList_cb &_hidl_cb) {
std::vector<hidl_string> deviceNameList; std::vector<hidl_string> deviceNameList;
for (auto const &deviceNamePair : mCameraDeviceNames) { for (auto const &deviceNamePair : mCameraDeviceNames) {
int id = std::stoi(deviceNamePair.first); int id = std::stoi(deviceNamePair.first);

View file

@ -30,7 +30,7 @@ public:
SamsungCameraProvider(); SamsungCameraProvider();
~SamsungCameraProvider(); ~SamsungCameraProvider();
Return<void> getCameraIdList(ICameraProvider::getCameraIdList_cb _hidl_cb); Return<void> getCameraIdList(const ICameraProvider::getCameraIdList_cb &_hidl_cb);
private: private:
std::vector<int> mExtraIDs; std::vector<int> mExtraIDs;

View file

@ -22,7 +22,7 @@ static int mSwapSize = 100;
extern int mkswap (std::string filename); extern int mkswap (std::string filename);
extern void mkfile(int filesize, std::string name); extern void mkfile(int filesize, std::string name);
#define SWAP_PATH "/data/swap/swapfile" static std::string SWAP_PATH = "/data/swap/swapfile";
namespace vendor::eureka::hardware::parts::V1_0 { namespace vendor::eureka::hardware::parts::V1_0 {
@ -34,13 +34,13 @@ Return<void> SwapOnData::setSwapSize(int32_t size) {
Return<void> SwapOnData::setSwapOn() { Return<void> SwapOnData::setSwapOn() {
mkfile(mSwapSize * 1024 * 1024 * 10, SWAP_PATH); mkfile(mSwapSize * 1024 * 1024 * 10, SWAP_PATH);
mkswap(SWAP_PATH); mkswap(SWAP_PATH);
swapon(SWAP_PATH, (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK); swapon(SWAP_PATH.c_str(), (10 << SWAP_FLAG_PRIO_SHIFT) & SWAP_FLAG_PRIO_MASK);
return Void(); return Void();
} }
Return<void> SwapOnData::setSwapOff() { Return<void> SwapOnData::setSwapOff() {
swapoff(SWAP_PATH); swapoff(SWAP_PATH.c_str());
remove(SWAP_PATH); remove(SWAP_PATH.c_str());
return Void(); return Void();
} }

View file

@ -18,7 +18,7 @@ struct linux_swap_header {
u_int32_t padding[117]; u_int32_t padding[117];
u_int32_t badpages[1]; u_int32_t badpages[1];
}; };
void mkfile(const int filesize, const std::string& name){ void mkfile(int filesize, std::string name){
FILE *fp = fopen(name.c_str(), "we"); FILE *fp = fopen(name.c_str(), "we");
fseek(fp, filesize , SEEK_SET); fseek(fp, filesize , SEEK_SET);
fputc('\0', fp); fputc('\0', fp);
@ -27,7 +27,7 @@ void mkfile(const int filesize, const std::string& name){
#define MAGIC_SWAP_HEADER "SWAPSPACE2" #define MAGIC_SWAP_HEADER "SWAPSPACE2"
#define MAGIC_SWAP_HEADER_LEN 10 #define MAGIC_SWAP_HEADER_LEN 10
#define MIN_PAGES 10 #define MIN_PAGES 10
int mkswap(const std::string& filename) { int mkswap(std::string filename) {
int err = 0; int err = 0;
int fd; int fd;
ssize_t len; ssize_t len;