From 2b08fd405e3f4a22fd1f7b890e084a3057fb78ee Mon Sep 17 00:00:00 2001 From: Zdenek Styblik Date: Sat, 26 Oct 2013 18:37:00 +0000 Subject: [PATCH] ID: 46 - ipmi_fwum needs some re-work KfwumMain() - change code formatting Commit changes code formatting of KfwumMain() into readable form and to make sense out of it. --- ipmitool/lib/ipmi_fwum.c | 203 +++++++++++++++------------------------ 1 file changed, 75 insertions(+), 128 deletions(-) diff --git a/ipmitool/lib/ipmi_fwum.c b/ipmitool/lib/ipmi_fwum.c index 7c005e7..8da9c08 100644 --- a/ipmitool/lib/ipmi_fwum.c +++ b/ipmitool/lib/ipmi_fwum.c @@ -313,135 +313,82 @@ typedef enum eFWUM_CmdId *******************************************************************************/ static void KfwumMain(struct ipmi_intf * intf, tKFWUM_Task task) { - tKFWUM_Status status = KFWUM_STATUS_OK; - tKFWUM_BoardInfo boardInfo; - tKFWUM_InFirmwareInfo firmInfo = { 0 }; - unsigned long fileSize = 0; - static unsigned short padding; - - if((status == KFWUM_STATUS_OK) && (task == KFWUM_TASK_INFO)) - { - unsigned char notUsed; - if(verbose) - { - printf("Getting Kontron FWUM Info\n"); - } - KfwumGetDeviceInfo(intf, 1, &boardInfo); - KfwumGetInfo(intf, 1, ¬Used); - - } - - - if((status == KFWUM_STATUS_OK) && (task == KFWUM_TASK_STATUS)) - { - if(verbose) - { - printf("Getting Kontron FWUM Status\n"); - } - KfwumGetStatus(intf); - } - - if( (status == KFWUM_STATUS_OK) && (task == KFWUM_TASK_ROLLBACK) ) - { - status = KfwumManualRollback(intf); - } - - if( - (status == KFWUM_STATUS_OK) && - ( - (task == KFWUM_TASK_UPGRADE) || (task == KFWUM_TASK_DOWNLOAD) - ) - ) - { - status = KfwumGetFileSize(fileName, &fileSize); - if(status == KFWUM_STATUS_OK) - { - status = KfwumSetupBuffersFromFile(fileName, fileSize); - if(status == KFWUM_STATUS_OK) - { - padding = KfwumCalculateChecksumPadding(firmBuf, fileSize); - } - } - if(status == KFWUM_STATUS_OK) - { - status = KfwumGetInfoFromFirmware(firmBuf, fileSize, &firmInfo); - } - if(status == KFWUM_STATUS_OK) - { - status = KfwumGetDeviceInfo(intf, 0, &boardInfo); - } - - if(status == KFWUM_STATUS_OK) - { - status = KfwumValidFirmwareForBoard(boardInfo,firmInfo); - } - - if (status == KFWUM_STATUS_OK) - { - unsigned char notUsed; - KfwumGetInfo(intf, 0, ¬Used); - } - - KfwumOutputInfo(boardInfo,firmInfo); - } - - if( - (status == KFWUM_STATUS_OK) && - ( - (task == KFWUM_TASK_UPGRADE) || (task == KFWUM_TASK_DOWNLOAD) - ) - ) - { - status = KfwumStartFirmwareImage(intf, fileSize, padding); - } - - - if( - (status == KFWUM_STATUS_OK) && - ( - (task == KFWUM_TASK_UPGRADE) || (task == KFWUM_TASK_DOWNLOAD) - ) - ) - { - status = KfwumUploadFirmware(intf, firmBuf, fileSize); - } - - if( - (status == KFWUM_STATUS_OK) && - ( - (task == KFWUM_TASK_UPGRADE) || (task == KFWUM_TASK_DOWNLOAD) - ) - ) - { - status = KfwumFinishFirmwareImage(intf, firmInfo); - } - - if( - (status == KFWUM_STATUS_OK) && - ( - (task == KFWUM_TASK_UPGRADE) || (task == KFWUM_TASK_DOWNLOAD) - ) - ) - { - status = KfwumGetStatus(intf); - } - - if( - (status == KFWUM_STATUS_OK) && - ( - (task == KFWUM_TASK_UPGRADE) || (task == KFWUM_TASK_START_UPGRADE) - ) - ) - { - status = KfwumStartFirmwareUpgrade(intf); - } - - if((status == KFWUM_STATUS_OK) && (task == KFWUM_TASK_TRACELOG)) - { - status = KfwumGetTraceLog(intf); - } - + tKFWUM_Status status = KFWUM_STATUS_OK; + tKFWUM_BoardInfo boardInfo; + tKFWUM_InFirmwareInfo firmInfo = { 0 }; + unsigned long fileSize = 0; + static unsigned short padding; + if ((status == KFWUM_STATUS_OK) && (task == KFWUM_TASK_INFO)) { + unsigned char notUsed; + if (verbose) { + printf("Getting Kontron FWUM Info\n"); + } + KfwumGetDeviceInfo(intf, 1, &boardInfo); + KfwumGetInfo(intf, 1, ¬Used); + } + if ((status == KFWUM_STATUS_OK) && (task == KFWUM_TASK_STATUS)) { + if (verbose) { + printf("Getting Kontron FWUM Status\n"); + } + KfwumGetStatus(intf); + } + if ((status == KFWUM_STATUS_OK) && (task == KFWUM_TASK_ROLLBACK)) { + status = KfwumManualRollback(intf); + } + if ((status == KFWUM_STATUS_OK) + && ((task == KFWUM_TASK_UPGRADE) + || (task == KFWUM_TASK_DOWNLOAD))) { + status = KfwumGetFileSize(fileName, &fileSize); + if (status == KFWUM_STATUS_OK) { + status = KfwumSetupBuffersFromFile(fileName, fileSize); + if (status == KFWUM_STATUS_OK) { + padding = KfwumCalculateChecksumPadding(firmBuf, fileSize); + } + } + if (status == KFWUM_STATUS_OK) { + status = KfwumGetInfoFromFirmware(firmBuf, fileSize, &firmInfo); + } + if (status == KFWUM_STATUS_OK) { + status = KfwumGetDeviceInfo(intf, 0, &boardInfo); + } + if (status == KFWUM_STATUS_OK) { + status = KfwumValidFirmwareForBoard(boardInfo,firmInfo); + } + if (status == KFWUM_STATUS_OK) { + unsigned char notUsed; + KfwumGetInfo(intf, 0, ¬Used); + } + KfwumOutputInfo(boardInfo,firmInfo); + } + if ((status == KFWUM_STATUS_OK) + && ((task == KFWUM_TASK_UPGRADE) + || (task == KFWUM_TASK_DOWNLOAD))) { + status = KfwumStartFirmwareImage(intf, fileSize, padding); + } + if ((status == KFWUM_STATUS_OK) + && ((task == KFWUM_TASK_UPGRADE) + || (task == KFWUM_TASK_DOWNLOAD))) { + status = KfwumUploadFirmware(intf, firmBuf, fileSize); + } + if ((status == KFWUM_STATUS_OK) + && ((task == KFWUM_TASK_UPGRADE) + || (task == KFWUM_TASK_DOWNLOAD))) { + status = KfwumFinishFirmwareImage(intf, firmInfo); + } + if ((status == KFWUM_STATUS_OK) + && ((task == KFWUM_TASK_UPGRADE) + || (task == KFWUM_TASK_DOWNLOAD))) { + status = KfwumGetStatus(intf); + } + if ((status == KFWUM_STATUS_OK) + && ((task == KFWUM_TASK_UPGRADE) + || (task == KFWUM_TASK_START_UPGRADE))) { + status = KfwumStartFirmwareUpgrade(intf); + } + if ((status == KFWUM_STATUS_OK) && (task == KFWUM_TASK_TRACELOG)) { + status = KfwumGetTraceLog(intf); + } } /* KfwumGetFileSize - gets the file size