BugFix 2: fix errors found by cppcheck

Change-Id: I262af4dcf3ad1dca9d7e7d88838ae90323303c1d
Reviewed-on: https://review.haiku-os.org/c/1294
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
Lee Mon 2019-03-13 21:17:28 +03:00 committed by waddlesplash
parent 446dc38f89
commit d04d9b2519
8 changed files with 11 additions and 8 deletions

View File

@ -47,6 +47,7 @@ FileSystemVisitor::Next()
while (true) { while (true) {
const char* name = NULL; const char* name = NULL;
char treeName[B_FILE_NAME_LENGTH];
Inode* inode; Inode* inode;
Vnode vnode; Vnode vnode;
@ -97,7 +98,6 @@ FileSystemVisitor::Next()
vnode.Keep(); vnode.Keep();
} }
} else { } else {
char treeName[B_FILE_NAME_LENGTH];
uint16 length; uint16 length;
ino_t id; ino_t id;

View File

@ -91,7 +91,7 @@ atari_identify_partition(int fd, partition_data *partition, void **_cookie)
if (arb->Checksum() == 0x55aa) if (arb->Checksum() == 0x55aa)
weight -= 0.1; /* possible but likely a PC sector */ weight -= 0.1; /* possible but likely a PC sector */
if (arb->_reserved_1[1] != 0x00) if (arb->_reserved_1[0] != 0x00)
weight -= 10; weight -= 10;
/* hope so */ /* hope so */
if (arb->MaxPartitionSize() < 10) if (arb->MaxPartitionSize() < 10)

View File

@ -504,7 +504,7 @@ int mapname(__G__ renamed)
!= (RO_extra_block *)NULL) != (RO_extra_block *)NULL)
{ {
/* file *must* have a RISC OS extra field */ /* file *must* have a RISC OS extra field */
long ft = (long)makelong((ef_spark->loadaddr); long ft = (long)makelong(ef_spark->loadaddr);
/*32-bit*/ /*32-bit*/
if (lastcomma) { if (lastcomma) {
pp = lastcomma + 1; pp = lastcomma + 1;

View File

@ -464,6 +464,8 @@ ShelfContainerViewFilter::_ObjectDropFilter(BMessage *msg, BHandler **_handler)
BDragger *dragger = NULL; BDragger *dragger = NULL;
if (handler) if (handler)
dragger = dynamic_cast<BDragger*>(handler); dragger = dynamic_cast<BDragger*>(handler);
else
return B_SKIP_MESSAGE;
BRect rect; BRect rect;
if (dragger->fRelation == BDragger::TARGET_IS_CHILD) if (dragger->fRelation == BDragger::TARGET_IS_CHILD)

View File

@ -522,7 +522,7 @@ BDeskWindow::AddWindowContextMenus(BMenu* menu)
#ifdef CUT_COPY_PASTE_IN_CONTEXT_MENU #ifdef CUT_COPY_PASTE_IN_CONTEXT_MENU
BMenuItem* pasteItem = new BMenuItem(B_TRANSLATE("Paste"), BMenuItem* pasteItem = new BMenuItem(B_TRANSLATE("Paste"),
new BMessage(B_PASTE), 'V')); new BMessage(B_PASTE), 'V');
menu->AddItem(pasteItem); menu->AddItem(pasteItem);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
#endif #endif

View File

@ -606,7 +606,7 @@ BNavMenu::NewModelItem(Model* model, const BMessage* invokeMessage,
if (newResolvedModel->InitCheck() != B_OK) { if (newResolvedModel->InitCheck() != B_OK) {
// broken link, still can show though, bail // broken link, still can show though, bail
delete newResolvedModel; delete newResolvedModel;
result = 0; result = NULL;
} else } else
result = newResolvedModel; result = newResolvedModel;
} }

View File

@ -178,7 +178,7 @@ scan_char (char *cp, char *valp)
} }
/* Scan a string delimited by white-space. Fails on empty string or /* Scan a string delimited by white-space. Fails on empty string or
if string is doesn't fit in the specified buffer. */ if string doesn't fit in the specified buffer. */
static inline char * static inline char *
scan_string (char *cp, char *valp, size_t buf_size) scan_string (char *cp, char *valp, size_t buf_size)
{ {
@ -195,7 +195,8 @@ scan_string (char *cp, char *valp, size_t buf_size)
} }
if (i == 0 || i >= buf_size) if (i == 0 || i >= buf_size)
return NULL; return NULL;
valp[i] = '\0'; if (valp != NULL)
valp[i] = '\0';
return cp; return cp;
} }

View File

@ -614,8 +614,8 @@ getaddrinfo(const char *hostname, const char *servname,
cur = cur->ai_next; cur = cur->ai_next;
} }
} }
}
#endif #endif
}
/* XXX */ /* XXX */
if (sentinel.ai_next) if (sentinel.ai_next)