Merge "Fix indentation and style issues in fm_cli"

This commit is contained in:
Zuul 2019-09-18 13:50:08 +00:00 committed by Gerrit Code Review
commit 206e5c4745
1 changed files with 145 additions and 132 deletions

View File

@ -12,20 +12,24 @@
#include <string.h>
#include <string>
void error(const char *add = "") {
printf("%s\n", add);
exit(-1);
}
void ok(const char *s = "") {
printf("Ok\n%s%s", s, strlen(s) != 0 ? "\n" : "");
exit(0);
}
void ok(fm_uuid_t *uuid) {
return ok(*uuid);
}
void create_alarm(const char *al) {
SFmAlarmDataT alarm;
EFmErrorT rc;
@ -46,6 +50,7 @@ void create_alarm(const char *al) {
ok(&uuid);
}
void delete_alarms(const char *id) {
fm_ent_inst_t inst_id;
EFmErrorT rc;
@ -60,6 +65,7 @@ void delete_alarms(const char *id) {
ok();
}
void delete_alarm(const char *f) {
AlarmFilter af;
EFmErrorT rc;
@ -75,6 +81,7 @@ void delete_alarm(const char *f) {
ok();
}
void get_alarm(const char *f) {
AlarmFilter af;
EFmErrorT rc;
@ -96,6 +103,7 @@ void get_alarm(const char *f) {
ok(s.c_str());
}
void get_alarms(const char *id) {
fm_ent_inst_t inst_id;
EFmErrorT rc;
@ -104,8 +112,11 @@ void get_alarms(const char *id) {
strncpy(inst_id, id, sizeof(inst_id) - 1);
unsigned int max_alarms = 500;
SFmAlarmDataT *p = (SFmAlarmDataT*)malloc(max_alarms*sizeof(SFmAlarmDataT));
if (p==NULL) error("Not enough memory...");
SFmAlarmDataT *p = (SFmAlarmDataT*) \
malloc(max_alarms * sizeof(SFmAlarmDataT));
if (p == NULL)
error("Not enough memory...");
if ((rc = fm_get_faults(&inst_id, p, &max_alarms)) != FM_ERR_OK) {
free(p);
std::string errstr = fm_error_from_int(rc);
@ -123,6 +134,7 @@ void get_alarms(const char *id) {
exit(0);
}
void get_alarms_by_id(const char *id) {
fm_alarm_id alm_id;
EFmErrorT rc;
@ -132,7 +144,9 @@ void get_alarms_by_id(const char *id) {
unsigned int max_alarms = 500;
SFmAlarmDataT *p = (SFmAlarmDataT*)malloc(max_alarms*sizeof(SFmAlarmDataT));
if (p==NULL) error("Not enough memory...");
if (p == NULL)
error("Not enough memory...");
if ((rc = fm_get_faults_by_id(&alm_id, p, &max_alarms)) != FM_ERR_OK) {
free(p);
std::string errstr = fm_error_from_int(rc);
@ -150,6 +164,7 @@ void get_alarms_by_id(const char *id) {
exit(0);
}
int main(int argc, char **argv) {
int c;
@ -184,5 +199,3 @@ int main(int argc, char**argv) {
return 0;
}