Skip to content

Commit 3f47f5c

Browse files
author
JerryWang
committed
Fixed for coding sytle
1 parent 69701d5 commit 3f47f5c

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

plugins/transcend/transcend-nvme.c

+11-22
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ static int getHealthValue(int argc, char **argv, struct command *cmd, struct plu
8888

8989
if (percent_used > 100 || percent_used < 0) {
9090
printf("0%%\n");
91-
}
92-
else {
91+
} else {
9392
healthvalue = 100 - percent_used;
9493
printf("%d%%\n", healthvalue);
9594
}
@@ -200,8 +199,7 @@ static int getPLPHealth(int argc, char **argv, struct command *cmd, struct plugi
200199
if (result) {
201200
printf("\nThis device is not support.\n");
202201
return -1;
203-
}
204-
else {
202+
} else {
205203
char modelName[40];
206204
const char *model_str_byte;
207205
model_str_byte = format_char_array((char *)modelName, sizeof(modelName), dataID, sizeof(dataID));
@@ -215,8 +213,7 @@ static int getPLPHealth(int argc, char **argv, struct command *cmd, struct plugi
215213
if (txtPLPHealth >= 0) {
216214
plpHealth_percentage = txtPLPHealth;
217215
printf("Capacitor health for PLP: %d%%\n", plpHealth_percentage);
218-
}
219-
else {
216+
} else {
220217
unsigned char data[512];
221218
struct nvme_passthru_cmd nvmecmd;
222219

@@ -230,8 +227,7 @@ static int getPLPHealth(int argc, char **argv, struct command *cmd, struct plugi
230227
if (result) {
231228
printf("\nGet PLP Health Fail.\n");
232229
return PLP_ERROR_NO_MATCH;
233-
}
234-
else {
230+
} else {
235231
int tDis = (int)(data[4 + 3] << 24) + (int)(data[4 + 2] << 16) + (int)(data[4 + 1] << 8) + (int)(data[4]);
236232
int vDis1 = (int)(data[0]);
237233
int vDis2 = (int)(data[1]);
@@ -240,19 +236,16 @@ static int getPLPHealth(int argc, char **argv, struct command *cmd, struct plugi
240236

241237
if (vDis1 - vDis2 != 0) {
242238
normalHealth = (iDis * tDis) / (vDis1 - vDis2);
243-
}
244-
else {
239+
} else {
245240
normalHealth = 0;
246241
}
247242
if (normalHealth >= 0) {
248243
if (fullValue - normalHealth >= 0) {
249244
plpHealth_percentage = (normalHealth / fullValue) * 100;
250-
}
251-
else {
245+
} else {
252246
plpHealth_percentage = 100;
253247
}
254-
}
255-
else {
248+
} else {
256249
plpHealth_percentage = 0;
257250
}
258251
printf("Capacitor health for PLP: %d%%\n", plpHealth_percentage);
@@ -314,8 +307,7 @@ int readUsefulPLPValue(const char *device)
314307
token = strtok(NULL, "#");
315308
ret = atoi(token);
316309
return ret;
317-
}
318-
else {
310+
} else {
319311
return PLP_ERROR_DATA_EXPIRED;
320312
}
321313
}
@@ -355,8 +347,7 @@ void recordPLPValue(const char *device, int value, bool isReplace)
355347
{
356348
if (strncmp(str, device, strlen(device)) == 0) {
357349
fprintf(fileout, "%s\n", line);
358-
}
359-
else {
350+
} else {
360351
fprintf(fileout, "%s", str);
361352
}
362353
}
@@ -365,12 +356,10 @@ void recordPLPValue(const char *device, int value, bool isReplace)
365356

366357
if (remove(logFilePath) == 0) {
367358
rename(tempFilePath, logFilePath);
368-
}
369-
else {
359+
} else {
370360
remove(tempFilePath);
371361
}
372-
}
373-
else {
362+
} else {
374363
FILE *out = fopen(logFilePath, "a");
375364
if (out == NULL) {
376365
perror("Error opening file");

0 commit comments

Comments
 (0)