* [9fans] test(1) -older bug?
@ 2013-06-01 21:15 arisawa
2013-06-01 21:59 ` erik quanstrom
0 siblings, 1 reply; 9+ messages in thread
From: arisawa @ 2013-06-01 21:15 UTC (permalink / raw)
To: 9fans
Hello,
How do you think?
I think test is buggy in "older" operation.
the test is from 9front. I have not tried bell-labs test.
term% ls -l
--rw-rw-r-- M 149 arisawa arisawa 3277 Apr 9 23:11 x
--rw-rw-r-- M 149 arisawa arisawa 4555 Apr 9 23:12 y
term% mtime x
1365516710 x
term% mtime y
1365516741 y
term% if(test x -ot y) echo OK
OK
term% if(test x -older 1365516741) echo OK
term% if(test x -older 1365516700) echo OK
term%
term% date -n
1370119926
term% dc
1370119926 1365516710 - p
4603216
term% if(test x -older 4603216) echo OK
OK
term% if(test x -older 4703216) echo OK
term%
term% man test
f -older t True if file f is older than (modified before)
time t. If t is a integer followed by the letters
y(years), M(months), d(days), h(hours),
m(minutes), or s(seconds), it represents current
time minus the specified time. If there is no
letter, it represents seconds since epoch. You
can also concatenate mixed units. For example,
3d12h means three days and twelve hours ago.
Kenji Arisawa
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] test(1) -older bug?
2013-06-01 21:15 [9fans] test(1) -older bug? arisawa
@ 2013-06-01 21:59 ` erik quanstrom
2013-06-02 21:29 ` cinap_lenrek
0 siblings, 1 reply; 9+ messages in thread
From: erik quanstrom @ 2013-06-01 21:59 UTC (permalink / raw)
To: 9fans
yup. i think it's a bug:
/n/sources/patch/older
/n/atom/patch/older
- erik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] test(1) -older bug?
2013-06-01 21:59 ` erik quanstrom
@ 2013-06-02 21:29 ` cinap_lenrek
2013-06-03 3:44 ` erik quanstrom
0 siblings, 1 reply; 9+ messages in thread
From: cinap_lenrek @ 2013-06-02 21:29 UTC (permalink / raw)
To: 9fans
its /n/sources/patch/testolder, also leaks dir in the case:
if(rel)
n = time(0) - n;
if(n < 0)
return 0; <----- HERE
r = dir->mtime < n;
free(dir);
return r;
--
cinap
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] test(1) -older bug?
2013-06-02 21:29 ` cinap_lenrek
@ 2013-06-03 3:44 ` erik quanstrom
2013-06-03 10:47 ` Richard Miller
0 siblings, 1 reply; 9+ messages in thread
From: erik quanstrom @ 2013-06-03 3:44 UTC (permalink / raw)
To: 9fans
On Sun Jun 2 17:31:05 EDT 2013, cinap_lenrek@gmx.de wrote:
> its /n/sources/patch/testolder, also leaks dir in the case:
>
> if(rel)
> n = time(0) - n;
> if(n < 0)
> return 0; <----- HERE
> r = dir->mtime < n;
>
> free(dir);
> return r;
thanks. i appreciate the catch.
[sources] applied patch: /n/atom/patch/applied/testolder1
email
quanstro@quanstro.net
readme
fix memory leak pointed out by cinap
removed
files
/sys/src/cmd/test.c test.c
/sys/src/cmd/test.c test.c
test.c.orig:373,380 - test.c:373,381
if(rel)
n = time(0) - n;
if(n < 0)
- return 0;
- r = dir->mtime < n;
+ r = 0;
+ else
+ r = dir->mtime < n;
free(dir);
return r;
------
merge...backup...copy...
cpfile test.c /n/dist/sys/src/cmd/test.c
done
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] test(1) -older bug?
2013-06-03 3:44 ` erik quanstrom
@ 2013-06-03 10:47 ` Richard Miller
2013-06-03 11:00 ` arnold
2013-06-03 11:08 ` Jacob Todd
0 siblings, 2 replies; 9+ messages in thread
From: Richard Miller @ 2013-06-03 10:47 UTC (permalink / raw)
To: 9fans
>> its /n/sources/patch/testolder, also leaks dir in the case:
>>
>> if(rel)
>> n = time(0) - n;
>> if(n < 0)
>> return 0; <----- HERE
>> r = dir->mtime < n;
>>
>> free(dir);
>> return r;
And the consequences of not freeing a few bytes of memory, in a command
which will exit a few microseconds later, would be ... ?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] test(1) -older bug?
2013-06-03 10:47 ` Richard Miller
@ 2013-06-03 11:00 ` arnold
2013-06-03 13:02 ` erik quanstrom
2013-06-03 11:08 ` Jacob Todd
1 sibling, 1 reply; 9+ messages in thread
From: arnold @ 2013-06-03 11:00 UTC (permalink / raw)
To: 9fans
Richard Miller <9fans@hamnavoe.com> wrote:
> And the consequences of not freeing a few bytes of memory, in a command
> which will exit a few microseconds later, would be ... ?
The Code Correctness Police come and collect you and force you to
program on Windows... <ducks>
:-)
Arnold
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] test(1) -older bug?
2013-06-03 10:47 ` Richard Miller
2013-06-03 11:00 ` arnold
@ 2013-06-03 11:08 ` Jacob Todd
2013-06-03 11:12 ` Richard Miller
1 sibling, 1 reply; 9+ messages in thread
From: Jacob Todd @ 2013-06-03 11:08 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
[-- Attachment #1: Type: text/plain, Size: 223 bytes --]
On Jun 3, 2013 6:49 AM, "Richard Miller" <9fans@hamnavoe.com> wrote:
> And the consequences of not freeing a few bytes of memory, in a command
> which will exit a few microseconds later, would be ... ?
>
>
bad taste.
[-- Attachment #2: Type: text/html, Size: 318 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] test(1) -older bug?
2013-06-03 11:08 ` Jacob Todd
@ 2013-06-03 11:12 ` Richard Miller
0 siblings, 0 replies; 9+ messages in thread
From: Richard Miller @ 2013-06-03 11:12 UTC (permalink / raw)
To: 9fans
> bad taste.
I agree - better style is to free memory always, or never. But the
choice might not be as obvious as one first thinks.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [9fans] test(1) -older bug?
2013-06-03 11:00 ` arnold
@ 2013-06-03 13:02 ` erik quanstrom
0 siblings, 0 replies; 9+ messages in thread
From: erik quanstrom @ 2013-06-03 13:02 UTC (permalink / raw)
To: 9fans
On Mon Jun 3 08:00:20 EDT 2013, arnold@skeeve.com wrote:
> Richard Miller <9fans@hamnavoe.com> wrote:
>
> > And the consequences of not freeing a few bytes of memory, in a command
> > which will exit a few microseconds later, would be ... ?
>
> The Code Correctness Police come and collect you and force you to
> program on Windows... <ducks>
excellent points. there is no consequence. but conversely, there is
no penalty for free'ing the memory either. given that, i prefer free'ing
the memory to be consistent with the rest of the source, and accept
cinap's bug as a bug.
of course you can say needless consistency is the hobgoblin of little
minds...
:-)
- erik
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-06-03 13:02 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-01 21:15 [9fans] test(1) -older bug? arisawa
2013-06-01 21:59 ` erik quanstrom
2013-06-02 21:29 ` cinap_lenrek
2013-06-03 3:44 ` erik quanstrom
2013-06-03 10:47 ` Richard Miller
2013-06-03 11:00 ` arnold
2013-06-03 13:02 ` erik quanstrom
2013-06-03 11:08 ` Jacob Todd
2013-06-03 11:12 ` Richard Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).