target: Fixed several clang-tidy warnings which improve readability of the code

This commit is contained in:
dragonmux 2022-07-14 16:22:38 -04:00 committed by Piotr Esden-Tempski
parent bdf4dc8731
commit 94b62ff924
2 changed files with 12 additions and 15 deletions

View File

@ -46,7 +46,7 @@ void target_list_free(void);
/* Attach/detach functions */
target *target_attach(target *t, struct target_controller *);
target *target_attach_n(int n, struct target_controller *);
target *target_attach_n(size_t n, struct target_controller *);
void target_detach(target *t);
bool target_attached(target *t);
const char *target_driver_name(target *t);
@ -179,4 +179,3 @@ struct target_controller {
};
#endif

View File

@ -159,21 +159,21 @@ void target_add_commands(target *t, const struct command_s *cmds, const char *na
struct target_command_s *tail;
for (tail = t->commands; tail->next; tail = tail->next);
tail->next = tc;
} else {
} else
t->commands = tc;
}
tc->specific_name = name;
tc->cmds = cmds;
tc->next = NULL;
}
target *target_attach_n(int n, struct target_controller *tc)
target *target_attach_n(const size_t n, struct target_controller *tc)
{
target *t;
int i;
for(t = target_list, i = 1; t; t = t->next, i++)
target *t = target_list;
for (size_t i = 1; t; t = t->next, ++i) {
if (i == n)
return target_attach(t, tc);
}
return NULL;
}
@ -277,8 +277,7 @@ int target_flash_erase(target *t, target_addr addr, size_t len)
return ret;
}
int target_flash_write(target *t,
target_addr dest, const void *src, size_t len)
int target_flash_write(target *t, target_addr dest, const void *src, size_t len)
{
int ret = 0;
while (len) {
@ -315,8 +314,7 @@ int target_flash_done(target *t)
return 0;
}
int target_flash_write_buffered(struct target_flash *f,
target_addr dest, const void *src, size_t len)
int target_flash_write_buffered(struct target_flash *f, target_addr dest, const void *src, size_t len)
{
int ret = 0;