From aae45bbcb48ce36a90b9e1c8217d850708b27abe Mon Sep 17 00:00:00 2001 From: Zotyamester Date: Sat, 18 Jan 2020 15:28:02 +0000 Subject: [PATCH] Fix 'always true' and 'always false' if statements Change-Id: If4056c8767184785b24489a678af498842e54cef Reviewed-on: https://review.haiku-os.org/c/haiku/+/2121 Reviewed-by: Adrien Destugues --- .../accelerants/matrox/InitAccelerant.c | 13 +++--- .../accelerants/nvidia/InitAccelerant.c | 16 ++++---- src/add-ons/accelerants/via/InitAccelerant.c | 16 ++++---- .../kernel/drivers/audio/emuxki/emuxki.c | 4 +- .../reiserfs/kernel_interface.cpp | 41 +++++++++---------- 5 files changed, 39 insertions(+), 51 deletions(-) diff --git a/src/add-ons/accelerants/matrox/InitAccelerant.c b/src/add-ons/accelerants/matrox/InitAccelerant.c index 17e51db1eb..1c130b7a2c 100644 --- a/src/add-ons/accelerants/matrox/InitAccelerant.c +++ b/src/add-ons/accelerants/matrox/InitAccelerant.c @@ -114,7 +114,8 @@ status_t INIT_ACCELERANT(int the_fd) result = init_common(the_fd); /* bail out if the common initialization failed */ - if (result != B_OK) goto error0; + if (result != B_OK) + goto error0; // LOG now available: !NULL si /* ensure that INIT_ACCELERANT is executed just once (copies should be clones) */ @@ -131,7 +132,8 @@ status_t INIT_ACCELERANT(int the_fd) result = gx00_general_powerup(); /* bail out if it failed */ - if (result != B_OK) goto error1; + if (result != B_OK) + goto error1; /* Now would be a good time to figure out what video modes your card supports. @@ -141,10 +143,8 @@ status_t INIT_ACCELERANT(int the_fd) Everybody else get's a read-only clone. */ result = create_mode_list(); - if (result != B_OK) - { + if (result != B_OK) goto error1; - } /* Put the cursor at the start of the frame buffer. The typical 64x64 4 color @@ -188,9 +188,6 @@ status_t INIT_ACCELERANT(int the_fd) /* note that overlay is not in use (for gx00_bes_move_overlay()) */ si->overlay.active = false; - /* bail out if something failed */ - if (result != B_OK) goto error1; - /* initialise various cursor stuff*/ gx00_crtc_cursor_init(); diff --git a/src/add-ons/accelerants/nvidia/InitAccelerant.c b/src/add-ons/accelerants/nvidia/InitAccelerant.c index e2fb8e255f..19ad2055fa 100644 --- a/src/add-ons/accelerants/nvidia/InitAccelerant.c +++ b/src/add-ons/accelerants/nvidia/InitAccelerant.c @@ -28,7 +28,8 @@ static status_t init_common(int the_fd) { gpd.magic = NV_PRIVATE_DATA_MAGIC; /* contact driver and get a pointer to the registers and shared data */ result = ioctl(fd, NV_GET_PRIVATE_DATA, &gpd, sizeof(gpd)); - if (result != B_OK) goto error0; + if (result != B_OK) + goto error0; /* clone the shared area for our use */ shared_info_area = clone_area(DRIVER_PREFIX " shared", (void **)&si, B_ANY_ADDRESS, @@ -112,7 +113,8 @@ status_t INIT_ACCELERANT(int the_fd) result = init_common(the_fd); /* bail out if the common initialization failed */ - if (result != B_OK) goto error0; + if (result != B_OK) + goto error0; // LOG now available: !NULL si /* ensure that INIT_ACCELERANT is executed just once (copies should be clones) */ @@ -126,7 +128,8 @@ status_t INIT_ACCELERANT(int the_fd) result = nv_general_powerup(); /* bail out if it failed */ - if (result != B_OK) goto error1; + if (result != B_OK) + goto error1; /* Now would be a good time to figure out what video modes your card supports. @@ -136,10 +139,8 @@ status_t INIT_ACCELERANT(int the_fd) Everybody else get's a read-only clone. */ result = create_mode_list(); - if (result != B_OK) - { + if (result != B_OK) goto error1; - } /* Put the cursor at the start of the frame buffer. @@ -188,9 +189,6 @@ status_t INIT_ACCELERANT(int the_fd) /* note that overlay is not in use (for nv_bes_move_overlay()) */ si->overlay.active = false; - /* bail out if something failed */ - if (result != B_OK) goto error1; - /* initialise various cursor stuff */ head1_cursor_init(); if (si->ps.secondary_head) head2_cursor_init(); diff --git a/src/add-ons/accelerants/via/InitAccelerant.c b/src/add-ons/accelerants/via/InitAccelerant.c index 2a4a83b9ab..1738c08fc0 100644 --- a/src/add-ons/accelerants/via/InitAccelerant.c +++ b/src/add-ons/accelerants/via/InitAccelerant.c @@ -28,7 +28,8 @@ static status_t init_common(int the_fd) { gpd.magic = VIA_PRIVATE_DATA_MAGIC; /* contact driver and get a pointer to the registers and shared data */ result = ioctl(fd, ENG_GET_PRIVATE_DATA, &gpd, sizeof(gpd)); - if (result != B_OK) goto error0; + if (result != B_OK) + goto error0; /* clone the shared area for our use */ shared_info_area = clone_area(DRIVER_PREFIX " shared", (void **)&si, B_ANY_ADDRESS, @@ -112,14 +113,16 @@ status_t INIT_ACCELERANT(int the_fd) { result = init_common(the_fd); /* bail out if the common initialization failed */ - if (result != B_OK) goto error0; + if (result != B_OK) + goto error0; // LOG now available: !NULL si /* call the device specific init code */ result = eng_general_powerup(); /* bail out if it failed */ - if (result != B_OK) goto error1; + if (result != B_OK) + goto error1; /* Now would be a good time to figure out what video modes your card supports. @@ -129,10 +132,8 @@ status_t INIT_ACCELERANT(int the_fd) { Everybody else get's a read-only clone. */ result = create_mode_list(); - if (result != B_OK) - { + if (result != B_OK) goto error1; - } /* Put the cursor at the start of the frame buffer. @@ -176,9 +177,6 @@ status_t INIT_ACCELERANT(int the_fd) { /* note that overlay is not in use (for eng_bes_move_overlay()) */ si->overlay.active = false; - /* bail out if something failed */ - if (result != B_OK) goto error1; - /* initialise various cursor stuff */ head1_cursor_init(); if (si->ps.secondary_head) head2_cursor_init(); diff --git a/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c b/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c index 21438a1499..560aac6b77 100644 --- a/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c +++ b/src/add-ons/kernel/drivers/audio/emuxki/emuxki.c @@ -1774,11 +1774,9 @@ emuxki_gpr_set(emuxki_dev *card, emuxki_gpr *gpr, int32 type, float *values) for (i = 0; i < count; i++) { if (values[i]>gpr->max_gain || values[i]min_gain) return; - index = (int32)(values[i] / gpr->granularity); + index = values[i] / gpr->granularity; if (index > sizeof(db_table)/sizeof(db_table[0])) index = sizeof(db_table)/sizeof(db_table[0]); - else if (index < 0) - index = 0; LOG(("emuxki_set_gpr gpr: %d \n", gpr->gpr + i)); LOG(("emuxki_set_gpr values[i]: %g \n", values[i])); LOG(("emuxki_set_gpr index: %u \n", index)); diff --git a/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp index 4152a55322..4f36f8b6a1 100644 --- a/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/reiserfs/kernel_interface.cpp @@ -572,30 +572,27 @@ FUNCTION(("node: (%Ld: %lu, %lu)\n", node->GetID(), node->GetDirID(), || (statData.IsEsoteric() && volume->GetHideEsoteric())) { continue; } + // get the name + size_t nameLen = 0; + const char *name = item.EntryNameAt(index, &nameLen); + if (!name || nameLen == 0) // bad data: skip it gracefully + continue; + // fill in the entry name -- checks whether the + // entry fits into the buffer + error = set_dirent_name(buffer, bufferSize, name, nameLen); if (error == B_OK) { - // get the name - size_t nameLen = 0; - const char *name = item.EntryNameAt(index, &nameLen); - if (!name || nameLen == 0) // bad data: skip it gracefully - continue; - // fill in the entry name -- checks whether the - // entry fits into the buffer - error = set_dirent_name(buffer, bufferSize, name, - nameLen); - if (error == B_OK) { - // fill in the other data - buffer->d_dev = volume->GetID(); - buffer->d_ino = VNode::GetIDFor(dirID, objectID); - *count = 1; + // fill in the other data + buffer->d_dev = volume->GetID(); + buffer->d_ino = VNode::GetIDFor(dirID, objectID); + *count = 1; PRINT(("Successfully read entry: dir: (%Ld: %ld, %ld), name: `%s', " - "id: (%Ld, %ld, %ld), reclen: %hu\n", node->GetID(), node->GetDirID(), - node->GetObjectID(), buffer->d_name, buffer->d_ino, dirID, objectID, - buffer->d_reclen)); - if (!strcmp("..", buffer->d_name)) - iterator->SetEncounteredDotDot(true); - done = true; - } - } + "id: (%Ld, %ld, %ld), reclen: %hu\n", node->GetID(), node->GetDirID(), + node->GetObjectID(), buffer->d_name, buffer->d_ino, dirID, objectID, + buffer->d_reclen)); + if (!strcmp("..", buffer->d_name)) + iterator->SetEncounteredDotDot(true); + done = true; + } } if (error == B_ENTRY_NOT_FOUND) { if (iterator->EncounteredDotDot()) {