Skip to content

Fix clang errors and warnings #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion authentication.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ class AuthenticationContext
virtual void CopyPartitionSignature(BootImage& bi, std::list<Section*> sections, uint8_t* signatureBlock, Section* acSection) {};
virtual void RearrangeEndianess(uint8_t *array, uint32_t size) {};
virtual void AddAuthCertSizeToTotalFSBLSize(PartitionHeader* header) {};
virtual void CopySPKSignature(uint8_t* ptr) {};
virtual void SetKeyLength(Authentication::Type type) {};

void CreateSPKSignature(void);
Expand Down
5 changes: 5 additions & 0 deletions authkeys-versal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ VersalKey::VersalKey(const Key& otherKey)
eckey = EC_KEY_new_by_curve_name(NID_secp521r1);
}

#if REMOVED__PLEASE_CHECK_AND_REMOVE
// @todo this memory copy is broken in a number of ways and should be handled
// in the base constructor; this is left here for Xilinx to consider and sort
// out
memcpy(this, &otherKey, sizeof(Key));
#endif
}

/******************************************************************************/
Expand Down
15 changes: 14 additions & 1 deletion authkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Key::Key(const Key& otherKey)
E = new uint8_t [WORD_SIZE_IN_BYTES];
P = new uint8_t [keySize/2];
Q = new uint8_t [keySize/2];
memcpy(this,&otherKey,sizeof(Key));
*this = otherKey;
}

/******************************************************************************/
Expand Down Expand Up @@ -100,6 +100,19 @@ Key::~Key()
}

/******************************************************************************/
Key& Key::operator=(const Key& otherKey)
{
if (keySize == otherKey.keySize) {
memcpy(N, otherKey.N, keySize);
memcpy(N_ext, otherKey.N_ext, keySize);
memcpy(E, otherKey.E, WORD_SIZE_IN_BYTES);
memcpy(P, otherKey.P, keySize/2);
memcpy(Q, otherKey.Q, keySize/2);
memcpy(D, otherKey.D, keySize);
}
return *this;
}

void Key::ParsePublic(const std::string& filename)
{
Parse(filename,false);
Expand Down
2 changes: 2 additions & 0 deletions authkeys.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class Key
void SetKeyName(std::string);
static void GenerateRsaKeys(KeyGenerationStruct*);

Key& operator=(const Key& otherKey);

bool Loaded;
bool isSecret;
uint8_t *N; // modulus (2048 bits)
Expand Down
2 changes: 1 addition & 1 deletion bifoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ void BifOptions::ParseUserKeyFile(std::string inputFileName)
word.pop_back();
if (word == "user_key")
{
if (c > 7 && c < 0)
if (c > 7 || c < 0)
{
LOG_ERROR("The AES user keys available are from 0 to 7. user_key%d is not supported", c);
}
Expand Down
3 changes: 0 additions & 3 deletions bootgenexception.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ class BootGenExceptionClass : public std::exception
BootGenExceptionClass(const char* filename0, int line0, const std::string& msg0 )
: msg(msg0)
, filename(filename0)
, line(line0)
{
}

BootGenExceptionClass(const char* filename0, int line0, const char* format, ...)
: filename(filename0)
, line(line0)
{
va_list ap;
va_start(ap, format);
Expand All @@ -76,6 +74,5 @@ class BootGenExceptionClass : public std::exception
private:
std::string msg;
std::string filename;
int line;
};
#endif
2 changes: 1 addition & 1 deletion encryption-zynq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ void ZynqEncryptionContext::ReadEncryptionKeyFile(const std::string& inputFileNa
break;
}

char c;
char c = '\0';
if (word == "Key")
{
// First Word is "Key"
Expand Down
2 changes: 1 addition & 1 deletion partitionheadertable-zynqmp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void ZynqMpPartitionHeader::SetTotalPartitionLength(uint32_t len)
}

/******************************************************************************/
void ZynqMpPartitionHeader::SetNextPartitionHeaderOffset(void)
void ZynqMpPartitionHeader::SetNextPartitionHeaderOffset(uint32_t )
{
static PartitionHeader* prev_part_hdr = NULL;
if (prev_part_hdr != NULL)
Expand Down
6 changes: 3 additions & 3 deletions partitionheadertable-zynqmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ZynqMpPartitionHeader : public PartitionHeader
void ReadHeader(std::ifstream& ifs);
void ReadData(std::ifstream& ifs);
void RealignSectionDataPtr(void);

void SetEncryptedPartitionLength(uint32_t len);
void SetUnencryptedPartitionLength(uint32_t len);
void SetTotalPartitionLength(uint32_t len);
Expand All @@ -115,9 +115,9 @@ class ZynqMpPartitionHeader : public PartitionHeader
void SetAuthCertificateOffset(void);
void SetPartitionNumber(uint32_t partNum);
void SetChecksum(void);
void SetNextPartitionHeaderOffset(void);
void SetNextPartitionHeaderOffset(uint32_t addr);
void SetBitLoadAddress(bool load, uint32_t val);

bool IsBootloader(void) { return isBootloader; }
uint8_t GetDestinationDevice(void);
uint8_t GetEncryptFlag(void);
Expand Down
2 changes: 1 addition & 1 deletion partitionheadertable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ void PartitionHeaderTable::Link(BootImage &bi)
for(std::list<PartitionHeader*>::iterator partHdr = bi.partitionHeaderList.begin(); partHdr != bi.partitionHeaderList.end(); partHdr++)
{
(*partHdr)->Link(bi, NULL);
(*partHdr)->SetNextPartitionHeaderOffset();
(*partHdr)->SetNextPartitionHeaderOffset(0);
}

if (bi.bifOptions->GetHeaderAC() && ! bi.options.GetLegacyFlag())
Expand Down
2 changes: 1 addition & 1 deletion partitionheadertable.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class PartitionHeader : public BaseThing
virtual void SetPartitionNumber(uint32_t partNum) {}
virtual void SetChecksum(void) {}
virtual void SetReserved(void) {}
virtual void SetNextPartitionHeaderOffset(void) {}
virtual void SetNextPartitionHeaderOffset(uint32_t addr) {}
virtual void SetBitLoadAddress(bool load, uint32_t val) {}
virtual void SetPartitionSize(Binary::Length_t) {}

Expand Down