New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sv.c: Eliminate LGTM warning Comparison result is always the same #16798
Comments
From @jkeenanIn RT 133703, I attempted to address the result of a finding from the Links: lgtm rule for comparisons always giving same result: That ticket stalled when it became apparent that we didn't have a ##### ... and that that functionality was undertested. We provided better Please review the patch attached, which is smoking in this branch: smoke-me/jkeenan/davem/sv-c-comparison-same Thank you very much. |
From @jkeenanThis is perl 5, version 29, subversion 7 (v5.29.7 (v5.29.6-69-gc011174cae)) built for x86_64-linux Copyright 1987-2018, Larry Wall Perl may be copied only under the terms of either the Artistic License or the Complete documentation for Perl, including FAQ lists, should be found on |
From @jkeenan0001-If-comparison-is-always-true-while-1-should-suffice.patchFrom c011174cae6c7c1b06b39a053787028a1c9fa7cd Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Fri, 30 Nov 2018 10:33:07 -0500
Subject: [PATCH] If comparison is always true, while (1) should suffice.
Per suggestion by Dave Mitchell in RT 133703.
---
sv.c | 25 +++++++++++++------------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/sv.c b/sv.c
index bc06c6c659..d9a0f41689 100644
--- a/sv.c
+++ b/sv.c
@@ -8535,18 +8535,19 @@ Perl_sv_gets(pTHX_ SV *const sv, PerlIO *const fp, I32 append)
* null assign is a placeholder. */
rslast = rslen ? rsptr[rslen - 1] : '\0';
- if (rspara) { /* have to do this both before and after */
- do { /* to make sure file boundaries work right */
- if (PerlIO_eof(fp))
- return 0;
- i = PerlIO_getc(fp);
- if (i != '\n') {
- if (i == -1)
- return 0;
- PerlIO_ungetc(fp,i);
- break;
- }
- } while (i != EOF);
+ if (rspara) { /* have to do this both before and after */
+ /* to make sure file boundaries work right */
+ while (1) {
+ if (PerlIO_eof(fp))
+ return 0;
+ i = PerlIO_getc(fp);
+ if (i != '\n') {
+ if (i == -1)
+ return 0;
+ PerlIO_ungetc(fp,i);
+ break;
+ }
+ }
}
/* See if we know enough about I/O mechanism to cheat it ! */
--
2.17.1
|
From @iabynOn Sun, Dec 30, 2018 at 07:49:34AM -0800, James E Keenan (via RT) wrote:
Can we ditch the gratuitous whitespace changes on otherwise unaffected -- |
The RT System itself - Status changed from 'new' to 'open' |
From @xsawyerx On 1/2/19 10:57 AM, Dave Mitchell Please review the patch attached, which is smoking in this branch: smoke-me/jkeenan/davem/sv-c-comparison-same
(In the future, commits for whitespace are best done separately to
Dave, the whitespace is not your enemy. (Well, maybe it is... but |
From @tonycozOn Sun, 30 Dec 2018 07:49:34 -0800, jkeenan@pobox.com wrote:
It looks reasonable to me. Tony |
From @jkeenanOn Tue, 29 Jan 2019 23:30:32 GMT, tonyc wrote:
Thanks. Merged to blead in commit e8db349. -- |
@jkeenan - Status changed from 'open' to 'pending release' |
From @khwilliamsonThank you for filing this report. You have helped make Perl better. With the release today of Perl 5.30.0, this and 160 other issues have been Perl 5.30.0 may be downloaded via: If you find that the problem persists, feel free to reopen this ticket. |
@khwilliamson - Status changed from 'pending release' to 'resolved' |
Migrated from rt.perl.org#133744 (status was 'resolved')
Searchable as RT133744$
The text was updated successfully, but these errors were encountered: