ID: 46 - ipmi_fwum needs some re-work

KfwumShowProgress() - code formatting, fix

Commit fixes code formatting in KfwumShowProgress() and replaces ``unsigned
char'', which didn't make any sense, with a ``signed char'', resp. ``char''.
This commit is contained in:
Zdenek Styblik 2013-10-26 19:11:33 +00:00
parent 38121041c1
commit 49879b387c

View File

@ -151,8 +151,8 @@ static tKFWUM_Status KfwumGetFileSize(unsigned char * pFileName,
unsigned long * pFileSize); unsigned long * pFileSize);
static tKFWUM_Status KfwumSetupBuffersFromFile(unsigned char * pFileName, static tKFWUM_Status KfwumSetupBuffersFromFile(unsigned char * pFileName,
unsigned long fileSize); unsigned long fileSize);
static void KfwumShowProgress( const unsigned char * task, void KfwumShowProgress(const char *task, unsigned long current,
unsigned long current, unsigned long total); unsigned long total);
static unsigned short KfwumCalculateChecksumPadding(unsigned char * pBuffer, static unsigned short KfwumCalculateChecksumPadding(unsigned char * pBuffer,
unsigned long totalSize); unsigned long totalSize);
@ -444,7 +444,7 @@ static tKFWUM_Status KfwumSetupBuffersFromFile(unsigned char * pFileName,
rewind(pFileHandle); rewind(pFileHandle);
for (qty=0; qty < count; qty++) { for (qty=0; qty < count; qty++) {
KfwumShowProgress((const unsigned char *)"Reading Firmware from File", KfwumShowProgress("Reading Firmware from File",
qty, count); qty, count);
if (fread(&firmBuf[qty * MAX_BUFFER_SIZE], 1, if (fread(&firmBuf[qty * MAX_BUFFER_SIZE], 1,
MAX_BUFFER_SIZE, MAX_BUFFER_SIZE,
@ -459,8 +459,7 @@ static tKFWUM_Status KfwumSetupBuffersFromFile(unsigned char * pFileName,
} }
} }
if (status == KFWUM_STATUS_OK) { if (status == KFWUM_STATUS_OK) {
KfwumShowProgress((const unsigned char *)"Reading Firmware from File", KfwumShowProgress("Reading Firmware from File", 100, 100);
100, 100);
} }
fclose(pFileHandle); fclose(pFileHandle);
return status; return status;
@ -474,46 +473,36 @@ static tKFWUM_Status KfwumSetupBuffersFromFile(unsigned char * pFileName,
* current: progress * current: progress
* total : limit * total : limit
*/ */
#define PROG_LENGTH 42 # define PROG_LENGTH 42
void KfwumShowProgress( const unsigned char * task, unsigned long current , void
unsigned long total) KfwumShowProgress(const char *task, unsigned long current, unsigned long total)
{ {
static unsigned long staticProgress=0xffffffff; static unsigned long staticProgress=0xffffffff;
unsigned char spaces[PROG_LENGTH + 1]; unsigned char spaces[PROG_LENGTH + 1];
unsigned short hash; unsigned short hash;
float percent = ((float)current/total); float percent = ((float)current/total);
unsigned long progress = 100*(percent); unsigned long progress = 100*(percent);
if(staticProgress == progress) if (staticProgress == progress) {
{
/* We displayed the same last time.. so don't do it */ /* We displayed the same last time.. so don't do it */
return;
} }
else
{
staticProgress = progress; staticProgress = progress;
printf("%-25s : ", task); /* total 20 bytes */
hash = (percent * PROG_LENGTH);
printf("%-25s : ",task); /* total 20 bytes */
hash = ( percent * PROG_LENGTH );
memset(spaces,'#', hash); memset(spaces,'#', hash);
spaces[ hash ] = '\0'; spaces[hash] = '\0';
printf("%s", spaces);
memset(spaces, ' ', (PROG_LENGTH - hash));
spaces[(PROG_LENGTH - hash)] = '\0';
printf("%s", spaces ); printf("%s", spaces );
memset(spaces,' ',( PROG_LENGTH - hash ) ); printf(" %3ld %%\r", progress); /* total 7 bytes */
spaces[ ( PROG_LENGTH - hash ) ] = '\0'; if (progress == 100) {
printf("%s", spaces );
printf(" %3ld %%\r",progress); /* total 7 bytes */
if( progress == 100 )
{
printf("\n"); printf("\n");
} }
fflush(stdout); fflush(stdout);
}
} }
/* KfwumCalculateChecksumPadding /* KfwumCalculateChecksumPadding
@ -1130,16 +1119,14 @@ static tKFWUM_Status KfwumUploadFirmware(struct ipmi_intf * intf,
} }
if (status == KFWUM_STATUS_OK) { if (status == KFWUM_STATUS_OK) {
if ((address % 1024) == 0) { if ((address % 1024) == 0) {
KfwumShowProgress((const unsigned char *)\ KfwumShowProgress("Writting Firmware in Flash",
"Writting Firmware in Flash",
address, totalSize); address, totalSize);
} }
sequenceNumber++; sequenceNumber++;
} }
} while ((status == KFWUM_STATUS_OK) && (address < totalSize)); } while ((status == KFWUM_STATUS_OK) && (address < totalSize));
if (status == KFWUM_STATUS_OK) { if (status == KFWUM_STATUS_OK) {
KfwumShowProgress((const unsigned char *)\ KfwumShowProgress("Writting Firmware in Flash",
"Writting Firmware in Flash",
100, 100); 100, 100);
} }
return(status); return(status);