@@ -193,10 +193,8 @@ cdbResult uCDB::findNextValue() {
193193}
194194
195195int uCDB::readValue () {
196- int rt;
197-
198196 if ((state == KEY_FOUND) && valueBytesAvail) {
199- rt = cdb.read ();
197+ int rt = cdb.read ();
200198 if (rt != -1 ) {
201199 --valueBytesAvail;
202200 }
@@ -207,13 +205,11 @@ int uCDB::readValue() {
207205}
208206
209207int uCDB::readValue (void *buff, unsigned int byteNum) {
210- int br;
211-
212208 if (state == KEY_FOUND) {
213209 if (byteNum > valueBytesAvail) {
214210 byteNum = valueBytesAvail;
215211 }
216- br = cdb.read (buff, byteNum);
212+ int br = cdb.read (buff, byteNum);
217213 if (br > 0 ) {
218214 valueBytesAvail -= br;
219215 }
@@ -249,8 +245,7 @@ cdbResult uCDB::compareKey() {
249245
250246 // keyLen < CDB_BUFF_SIZE
251247 if (keyLen) {
252- // Compiler warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
253- if (cdb.read (buff, keyLen) != keyLen) {
248+ if (cdb.read (buff, keyLen) != (int )keyLen) {
254249 return FILE_ERROR;
255250 }
256251 if (memcmp (key, buff, keyLen)) {
@@ -268,21 +263,17 @@ bool uCDB::readDescriptor(byte *buff, unsigned long pos) {
268263 }
269264 }
270265
271- if (cdb.read (buff, CDB_DESCRIPTOR_SIZE) == CDB_DESCRIPTOR_SIZE) {
272- return true ;
273- }
274- else {
275- return false ;
276- }
266+ return (cdb.read (buff, CDB_DESCRIPTOR_SIZE) == CDB_DESCRIPTOR_SIZE);
277267}
278268
279269void uCDB::zero () {
280270 slotsToScan = 0 ;
281271 nextSlotPos = 0 ;
282272}
283-
273+
274+ #define DJB_START_HASH 5381UL
284275unsigned long DJBHash (const void *key, unsigned long keyLen) {
285- unsigned long h = 5381 ;
276+ unsigned long h = DJB_START_HASH ;
286277 const byte *curr = static_cast <const byte *>(key);
287278 const byte *end = curr + keyLen;
288279
@@ -293,6 +284,7 @@ unsigned long DJBHash(const void *key, unsigned long keyLen) {
293284
294285 return h;
295286}
287+ #undef DJB_START_HASH
296288
297289// Static functions
298290
0 commit comments