Commit 5c8eef33 authored by Adam Wujek's avatar Adam Wujek 💬

userspace/libwr: update checking return val of wrs_shm_get_and_check

Update callers of wrs_shm_get_and_check to recognize return value
WRS_SHM_INCONSISTENT_DATA. Update to use defined values instead of numbers.

Update:
--snmpd
--tools/rtu_stat
--tools/wr_mon
--tools/wr_phytool
--tools/wrs_sfp_dump
--tools/wrs_vlans
--wrs_watchdog
--wrsw_rtud
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 25028e46
......@@ -30,12 +30,16 @@ static int init_shm_hald(void)
n_wait++;
/* start printing error after 5 messages */
if (n_wait > 5) {
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
snmp_log(LOG_ERR, "Unable to open HAL's shmem!\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
snmp_log(LOG_ERR, "Unable to read HAL's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
snmp_log(LOG_ERR, "Unable to read consistent data from"
" HAL's shmem!\n");
}
}
if (ret) {
/* return if error while opening shmem */
......@@ -82,12 +86,16 @@ static int init_shm_ppsi(void)
/* start printing error after 5 messages */
if (n_wait > 5) {
/* timeout! */
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
snmp_log(LOG_ERR, "Unable to open shm for PPSI!\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
snmp_log(LOG_ERR, "Unable to read PPSI's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
snmp_log(LOG_ERR, "Unable to read consistent data from"
" PPSI's shmem!\n");
}
}
if (ret) {
/* return if error while opening shmem */
......@@ -128,12 +136,16 @@ static int init_shm_rtud(void)
n_wait++;
/* start printing error after 5 messages */
if (n_wait > 5) {
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
snmp_log(LOG_ERR, "Unable to open shm for RTUd!\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
snmp_log(LOG_ERR, "Unable to read RTUd's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
snmp_log(LOG_ERR, "Unable to read consistent data from"
" RTUd's shmem!\n");
}
}
if (ret) {
/* return if error while opening shmem */
......
......@@ -205,14 +205,18 @@ int get_nports_from_hal(void)
while ((ret = wrs_shm_get_and_check(wrs_shm_hal, &hal_head)) != 0) {
n_wait++;
if (n_wait > 10) {
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
fprintf(stderr, "rtu_stat: Unable to open "
"HAL's shm !\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
fprintf(stderr, "rtu_stat: Unable to read "
"HAL's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
fprintf(stderr, "rtu_stat: Unable to read "
"consistent data from HAL's shmem!\n");
}
exit(1);
}
sleep(1);
......@@ -329,14 +333,19 @@ int open_rtu_shm(void)
while ((ret = wrs_shm_get_and_check(wrs_shm_rtu, &rtu_port_shmem)) != 0) {
n_wait++;
if (n_wait > 10) {
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
fprintf(stderr, "rtu_stat: Unable to open "
"RTUd's shm !\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
fprintf(stderr, "rtu_stat: Unable to read "
"RTUd's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
fprintf(stderr, "rtu_stat: Unable to read "
"consistent data from RTUd's shmem!\n"
);
}
exit(1);
}
sleep(1);
......
......@@ -184,12 +184,16 @@ void init_shm(void)
int n_wait = 0;
while ((ret = wrs_shm_get_and_check(wrs_shm_hal, &hal_head)) != 0) {
n_wait++;
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
pr_error("Unable to open HAL's shm !\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
pr_error("Unable to read HAL's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
pr_error("Unable to read consistent data from HAL's "
"shmem!\n");
}
if (n_wait > 10) {
/* timeout! */
exit(-1);
......@@ -224,12 +228,16 @@ void init_shm(void)
n_wait = 0;
while ((ret = wrs_shm_get_and_check(wrs_shm_ptp, &ppsi_head)) != 0) {
n_wait++;
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
pr_error("Unable to open PPSI's shm !\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
pr_error("Unable to read PPSI's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
pr_error("Unable to read consistent data from PPSI's "
"shmem!\n");
}
if (n_wait > 10) {
/* timeout! */
exit(-1);
......
......@@ -65,14 +65,18 @@ int hal_shm_init(void)
while ((ret = wrs_shm_get_and_check(wrs_shm_hal, &hal_head)) != 0) {
n_wait++;
if (n_wait > 10) {
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
fprintf(stderr, "wr_phytool: Unable to open "
"HAL's shm !\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
fprintf(stderr, "wr_phytool: Unable to read "
"HAL's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
fprintf(stderr, "wr_phytool: Unable to read "
"consistent data from HAL's shmem!\n");
}
return(-1);
}
sleep(1);
......
......@@ -234,12 +234,16 @@ void hal_init_shm(void)
int n_wait = 0;
while ((ret = wrs_shm_get_and_check(wrs_shm_hal, &hal_head)) != 0) {
n_wait++;
if (ret == 1) {
pr_error("Unable to open HAL's shm !\n");
if (ret == WRS_SHM_OPEN_FAILED) {
pr_error("Unable to open HAL's shmem !\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
pr_error("Unable to read HAL's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
pr_error("Unable to read consistent data from HAL's "
"shmem!\n");
}
if (n_wait > 10) {
/* timeout! */
exit(1);
......
......@@ -192,12 +192,16 @@ int main(int argc, char *argv[])
while ((ret = wrs_shm_get_and_check(wrs_shm_rtu, &rtu_port_shmem)) != 0) {
n_wait++;
if (n_wait > 10) {
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
pr_error("Unable to open RTUd's shmem!\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
pr_error("Unable to read RTUd's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
pr_error("Unable to read consistent data from "
"RTUd's shmem!\n");
}
exit(1);
}
sleep(1);
......
......@@ -61,12 +61,16 @@ int get_nports_from_hal(void)
while ((ret = wrs_shm_get_and_check(wrs_shm_hal, &hal_head)) != 0) {
n_wait++;
if (n_wait > 10) {
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
pr_error("Unable to open HAL's shmem!\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
pr_error("Unable to read HAL's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
pr_error("Unable to read consistent data from "
"HAL's shmem!\n");
}
exit(1);
}
sleep(1);
......
......@@ -85,12 +85,16 @@ void init_shm(void)
/* print if waiting more than 10 seconds, some wait
* is expected since hal requires few seconds to start
*/
if (ret == 1) {
if (ret == WRS_SHM_OPEN_FAILED) {
pr_error("Unable to open HAL's shmem!\n");
}
if (ret == 2) {
if (ret == WRS_SHM_WRONG_VERSION) {
pr_error("Unable to read HAL's version!\n");
}
if (ret == WRS_SHM_INCONSISTENT_DATA) {
pr_error("Unable to read consistent data from "
"HAL's shmem!\n");
}
exit(1);
}
sleep(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment