Skip to content

Commit 7832b30

Browse files
niklas88Alexander Gordeev
authored andcommitted
s390/debug: Simplify and document debug_next_entry() logic
Contrary to convention debug_next_entry() returns a falsy 0 value if there are more entries and a truthy 1 value when there are no more entries. As there is only one caller just reverse this logic to be less surprising and document the behavior in a kdoc comment. Also replace the goto with an early return. In the future this allows using it in a do {} while (debug_next_entry(...)) loop. Reviewed-by: Halil Pasic <pasic@linux.ibm.com> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 4ec6054 commit 7832b30

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

arch/s390/kernel/debug.c

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -422,22 +422,28 @@ static int debug_format_entry(file_private_info_t *p_info)
422422
return len;
423423
}
424424

425-
/*
426-
* debug_next_entry:
427-
* - goto next entry in p_info
425+
/**
426+
* debug_next_entry - Go to the next entry
427+
* @p_info: Private info that is manipulated
428+
*
429+
* Sets the current position in @p_info to the next entry. If no further entry
430+
* exists the current position is set to one after the end the return value
431+
* indicates that no further entries exist.
432+
*
433+
* Return: True if there are more following entries, false otherwise
428434
*/
429-
static inline int debug_next_entry(file_private_info_t *p_info)
435+
static inline bool debug_next_entry(file_private_info_t *p_info)
430436
{
431437
debug_info_t *id;
432438

433439
id = p_info->debug_info_snap;
434440
if (p_info->act_entry == DEBUG_PROLOG_ENTRY) {
435441
p_info->act_entry = 0;
436442
p_info->act_page = 0;
437-
goto out;
443+
return true;
438444
}
439445
if (!id->areas)
440-
return 1;
446+
return false;
441447
p_info->act_entry += id->entry_size;
442448
/* switch to next page, if we reached the end of the page */
443449
if (p_info->act_entry > (PAGE_SIZE - id->entry_size)) {
@@ -450,10 +456,9 @@ static inline int debug_next_entry(file_private_info_t *p_info)
450456
p_info->act_page = 0;
451457
}
452458
if (p_info->act_area >= id->nr_areas)
453-
return 1;
459+
return false;
454460
}
455-
out:
456-
return 0;
461+
return true;
457462
}
458463

459464
/*
@@ -495,7 +500,7 @@ static ssize_t debug_output(struct file *file, /* file descriptor */
495500
}
496501
if (copy_size == formatted_line_residue) {
497502
entry_offset = 0;
498-
if (debug_next_entry(p_info))
503+
if (!debug_next_entry(p_info))
499504
goto out;
500505
}
501506
}

0 commit comments

Comments
 (0)