Skip to content

Commit

Permalink
Minor edits
Browse files Browse the repository at this point in the history
Jump to Lempty for zero-length source strings.  Remove dead code
claiming to reuse register for dnp->dn_reg.

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
  • Loading branch information
euloh authored and kvanhees committed Apr 22, 2022
1 parent 4e5539c commit f72a4ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions bpf/substr.S
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ dt_substr :

/*
* Get the source string length and validate it.
* If the return value of probe_read_str) is less than 0, an error
* occured, and the result will be the empty string.
* If the length is 0, the result is the empty string.
* If the return value of probe_read_str() is less than 0, an error
* occurred, and the result will be the empty string.
* If the length is 1, the result is the empty string.
* If the length is less than the maximum string length (STRSZ), use
* the length we got. (The length is initialized in %r8 as the default
* string length.)
Expand All @@ -55,7 +55,7 @@ dt_substr :
* len = probe_read_str(dst, STRSZ + 1,
* src);
*/
jslt %r0, 1, .Lempty /* if (len < 1) goto Lempty; */
jsle %r0, 1, .Lempty /* if (len <= 1) goto Lempty; */
sub %r0, 1 /* len--; */
mov %r4, %r8 /* %r4 = STRSZ (previously in %r8) */
mov %r8, %r0 /* %r8 = len */
Expand Down
1 change: 0 additions & 1 deletion libdtrace/dt_cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -4289,7 +4289,6 @@ dt_cg_subr_strlen(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)

dt_cg_node(str, dlp, drp);
dt_cg_check_ptr_arg(dlp, drp, str);
dnp->dn_reg = str->dn_reg; /* re-use register */

if (dt_regset_xalloc_args(drp) == -1)
longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
Expand Down

0 comments on commit f72a4ff

Please sign in to comment.