I changed some warnings found in the svace test.
- I added a return check to some functions.
- Changed unnecessary variable settings.
Change-Id: Iaf4c2785dafe085e9a887ed0e8dc969bd398e244
Signed-off-by: Junhwan Park <junhwan.park@samsung.com>
Conflicts:
apps/examples/security_api/security_api_tc_main.c
for (j = 0; j < nbtns; j++) {
if (poll_list[j].revents & POLLIN) {
char buf[4];
- lseek(poll_list[j].fd, 0, SEEK_SET);
- read(poll_list[j].fd, buf, sizeof(buf));
+ if (lseek(poll_list[j].fd, 0, SEEK_SET) < 0) {
+ printf("lseek error\n");
+ return;
+ }
+ if (read(poll_list[j].fd, buf, sizeof(buf)) < 0) {
+ printf("read error\n");
+ return;
+ }
printf("%s is %s\n", buttons[j].name,
buf[0] == '1' ? "rising" : "falling");
static char devpath[16];
snprintf(devpath, 16, "/dev/gpio%d", port);
int fd = open(devpath, O_RDWR);
+ if (fd < 0) {
+ printf("fd open fail\n");
+ return;
+ }
ioctl(fd, GPIOIOC_SET_DIRECTION, GPIO_DIRECTION_OUT);
- write(fd, str, snprintf(str, 4, "%d", value != 0) + 1);
+ if (write(fd, str, snprintf(str, 4, "%d", value != 0) + 1) < 0) {
+ printf("write error\n");
+ return;
+ }
close(fd);
}
char devpath[16];
snprintf(devpath, 16, "/dev/gpio%d", port);
int fd = open(devpath, O_RDWR);
+ if (fd < 0) {
+ printf("fd open fail\n");
+ return -1;
+ }
- read(fd, buf, sizeof(buf));
+ if (read(fd, buf, sizeof(buf)) < 0) {
+ printf("read error\n");
+ return -1;
+ }
close(fd);
return buf[0] == '1';
char devpath[16];
snprintf(devpath, 16, "/dev/gpio%d", port);
int fd = open(devpath, O_RDWR);
+ if (fd < 0) {
+ printf("fd open fail\n");
+ return;
+ }
ioctl(fd, GPIOIOC_SET_DIRECTION, GPIO_DIRECTION_OUT);
- write(fd, buf, snprintf(buf, sizeof(buf), "%d", !!value));
+ if (write(fd, buf, snprintf(buf, sizeof(buf), "%d", !!value)) < 0) {
+ printf("write error\n");
+ return;
+ }
close(fd);
}
nA = XGPIO1;
nB = XGPIO3;
break;
- default:
- break;
}
int readA, readB;
int fd = open(devpath, O_RDWR);
ioctl(fd, GPIOIOC_SET_DIRECTION, GPIO_DIRECTION_IN);
- read(fd, buf, sizeof(buf));
+ if (read(fd, buf, sizeof(buf)) < 0) {
+ printf("read error\n");
+ return -1;
+ }
close(fd);
return buf[0] == '1';
int fd = open(devpath, O_RDWR);
ioctl(fd, GPIOIOC_SET_DIRECTION, GPIO_DIRECTION_OUT);
- write(fd, buf, snprintf(buf, sizeof(buf), "%d", !!value));
+ if (write(fd, buf, snprintf(buf, sizeof(buf), "%d", !!value)) < 0) {
+ printf("write error\n");
+ return;
+ }
close(fd);
}
for (i = 0; i < 30; i++) {
data[0] = mpu9250_get_axis(MPU9250_AXIS_X);
- if (data[0] < 0) {
- break;
- }
-
data[1] = mpu9250_get_axis(MPU9250_AXIS_Y);
- if (data[1] < 0) {
- break;
- }
-
data[2] = mpu9250_get_axis(MPU9250_AXIS_Z);
- if (data[2] < 0) {
- break;
- }
printf("ACC: %-10d%-10d%-10d\n", (int16_t)data[0], (int16_t)data[1], (int16_t)data[2]);
-
up_mdelay(500);
}
static void tcs34725_initialize(void)
{
- uint8_t reg;
+ uint8_t reg = 0;
tcs34725IntegrationTime = TCS34725_INTEGRATIONTIME_50MS;
tcs34725_read(TCS34725_ID, ®, 1);
tcs34725_initialize();
+ r = g = b = c = temp = lux = 0;
for (i = 0; i < 30; i++) {
tcs34725_getdata(&r, &g, &b, &c);
/* device 0 channel 1 */
fd = open("/dev/pwm1", O_RDWR);
+ if (fd < 0) {
+ printf("fd open fail\n");
+ return;
+ }
for (i = 0; i < 8; i++) {
pwm_info.frequency = octavef1[i];
/* device 0 channel 2 */
fd = open("/dev/pwm2", O_RDWR);
+ if (fd < 0) {
+ printf("fd open fail\n");
+ return;
+ }
for (i = 0; i < 8; i++) {
pwm_info.frequency = octavef2[i];
struct pwm_info_s pwm_info;
fd1 = open("/dev/pwm0", O_RDWR);
+ if (fd1 < 0) {
+ printf("fd open fail\n");
+ return;
+ }
fd2 = open("/dev/pwm3", O_RDWR);
+ if (fd2 < 0) {
+ printf("fd open fail\n");
+ return;
+ }
fd3 = open("/dev/pwm4", O_RDWR);
+ if (fd3 < 0) {
+ printf("fd open fail\n");
+ return;
+ }
fd4 = open("/dev/pwm5", O_RDWR);
+ if (fd4 < 0) {
+ printf("fd open fail\n");
+ return;
+ }
pwm_info.frequency = 1000;
for (i = 0; i < 100; i = i + 3) {