Skip to content

Commit

Permalink
Couple of details here and there
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Aug 27, 2024
1 parent 738d9b4 commit 8f46df8
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ _✔️ - supported, ↻ - in development, ✗ - unsupported, ⁿ/ₐ - not supp

_* At the moment, only text, 24-bit and 32-bit RGB overlays are handled, matricial formats and covers are to follow_

[^1]: CV181x\[C/H\], SG2000 and SG2002
[^1]: CV181x\[C/H\], SG200\[0/2\]
[^2]: GM813\[5/6/8\]\(S\)
[^3]: Hi3516AV100 and Hi3516DV100
[^4]: Hi3516CV100, Hi3518AV100, Hi3518CV100 and Hi3518EV100
Expand Down
5 changes: 0 additions & 5 deletions src/app_config.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#include "app_config.h"

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const char *appconf_paths[] = {"./divinus.yaml", "/etc/divinus.yaml"};

struct AppConfig app_config;
Expand Down
6 changes: 6 additions & 0 deletions src/app_config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#pragma once

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include "hal/config.h"
#include "hal/support.h"

Expand Down
20 changes: 10 additions & 10 deletions src/hal/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ enum ConfigError find_sections(struct IniConfig *ini) {

regex_t regex;
if (compile_regex(&regex, REG_SECTION) < 0) {
printf("compile_regex error\n");
HAL_DANGER("config", "Error compiling regex!\n");
return CONFIG_REGEX_ERROR;
};

Expand Down Expand Up @@ -71,7 +71,7 @@ enum ConfigError parse_param_value(
ssize_t reg_buf_len = sprintf(reg_buf, REG_PARAM, param_name);
reg_buf[reg_buf_len] = 0;
if (compile_regex(&regex, reg_buf) < 0) {
printf("compile_regex error\n");
HAL_DANGER("config", "Error compiling regex!\n");
return CONFIG_REGEX_ERROR;
};

Expand Down Expand Up @@ -118,7 +118,7 @@ enum ConfigError parse_enum(
}

// print error
printf(
HAL_DANGER("config",
"Can't parse param '%s' value '%s'. Is not a number and is not in "
"possible values: ",
param_name, param_value);
Expand Down Expand Up @@ -167,7 +167,7 @@ enum ConfigError parse_int(
}
if (!*end) {
if (res < min || res > max) {
printf(
HAL_DANGER("config",
"Can't parse param '%s' value '%s'. Value '%ld' is not in a "
"range [%d; %d].",
param_name, param_value, res, min, max);
Expand All @@ -185,7 +185,7 @@ enum ConfigError parse_int(
return CONFIG_OK;
}

printf(
HAL_DANGER("config",
"Can't parse param '%s' value '%s'. Is not a integer (dec or hex) "
"number.",
param_name, param_value);
Expand All @@ -208,7 +208,7 @@ enum ConfigError parse_array(
if (*end)
res = strtol(token, &end, 16);
if (*end) {
printf(
HAL_DANGER("config",
"Can't parse param '%s' value '%s'. Is not a integer (dec or "
"hex) number.",
param_name, token);
Expand Down Expand Up @@ -238,7 +238,7 @@ enum ConfigError parse_uint64(
}
if (!*end) {
if (res < min || res > max) {
printf(
HAL_DANGER("config",
"Can't parse param '%s' value '%s'. Value '%lld' is not in a "
"range [%lld; %lld].\n",
param_name, param_value, res, min, max);
Expand All @@ -256,7 +256,7 @@ enum ConfigError parse_uint64(
return CONFIG_OK;
}

printf(
HAL_DANGER("config",
"Can't parse param '%s' value '%s'. Is not a integer (dec or hex) "
"number.",
param_name, param_value);
Expand Down Expand Up @@ -286,14 +286,14 @@ bool open_config(struct IniConfig *ini, FILE **file) {

ini->str = malloc(length + 1);
if (!ini->str) {
printf("Can't allocate buf in parse_sensor_config\n");
HAL_DANGER("config", "Cannot allocate buffer to hold the config file!\n");
fclose(*file);
return false;
}

size_t n = fread(ini->str, 1, length, *file);
if (n != length) {
printf("Can't read all file\n");
HAL_DANGER("config", "Cannot read the whole config file!\n");
fclose(*file);
free(ini->str);
return false;
Expand Down
1 change: 1 addition & 0 deletions src/hal/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdlib.h>
#include <string.h>

#include "macros.h"
#include "tools.h"

#define MAX_SECTIONS 16
Expand Down
8 changes: 4 additions & 4 deletions src/hal/support.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void hal_identify(void) {
char line[200] = {0};

#ifdef __arm__
if (!access("/proc/mi_modules", 0) &&
if (!access("/proc/mi_modules", F_OK) &&
hal_registry(0x1F003C00, &series, OP_READ)) {
switch (series) {
case 0xEF: // Macaron (6)
Expand Down Expand Up @@ -100,7 +100,7 @@ void hal_identify(void) {
}
}

if (!access("/dev/vpd", 0)) {
if (!access("/dev/vpd", F_OK)) {
plat = HAL_PLATFORM_GM;
strcpy(chip, "GM813x");
if (file = fopen("/proc/pmu/chipver", "r")) {
Expand All @@ -118,7 +118,7 @@ void hal_identify(void) {
#endif

#ifdef __mips__
if (!access("/proc/jz", 0) &&
if (!access("/proc/jz", F_OK) &&
hal_registry(0x1300002C, &val, OP_READ)) {
unsigned int type;
hal_registry(0x13540238, &type, OP_READ);
Expand Down Expand Up @@ -233,7 +233,7 @@ void hal_identify(void) {
#endif

#if defined(__riscv) || defined(__riscv__)
if (!access("/proc/cvi", 0)) {
if (!access("/proc/cvi", F_OK)) {
plat = HAL_PLATFORM_CVI;
strcpy(family, "CV181x");
chnCount = CVI_VENC_CHN_NUM;
Expand Down
2 changes: 1 addition & 1 deletion src/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ int start_sdk(void) {
pthread_attr_destroy(&thread_attr);
}

if (!access(app_config.sensor_config, 0) && !sleep(1))
if (!access(app_config.sensor_config, F_OK) && !sleep(1))
switch (plat) {
#if defined(__arm__)
case HAL_PLATFORM_I6: i6_config_load(app_config.sensor_config); break;
Expand Down
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void *send_jpeg_thread(void *vargp) {
}

int send_file(const int client_fd, const char *path) {
if (access(path, F_OK) != -1) { // file exists
if (access(path, F_OK) != -1) {
const char *mime = (path);
FILE *file = fopen(path, "r");
if (file == NULL) {
Expand Down

0 comments on commit 8f46df8

Please sign in to comment.