Re: cdio: read_track: plug leak
> On Sep 10, 2017, at 9:35 PM, Michael W. Bombardieriwrote: > > Patch was also posted here, but I didn't test it. > https://marc.info/?l=openbsd-tech=149784342025304=2 omg we're twins
[Patch] Remove unnecessary assignment in pctr.c
Hi tech@ Remove unnecessary assignment. Thanks! Best Regards Nan Xiao Index: pctr.c === RCS file: /cvs/src/usr.bin/pctr/pctr.c,v retrieving revision 1.23 diff -u -p -r1.23 pctr.c --- pctr.c 10 Sep 2017 11:30:43 - 1.23 +++ pctr.c 11 Sep 2017 03:21:21 - @@ -190,7 +190,6 @@ pctr_cpu_creds(void) err(1, "CPU_CPUFEATURE"); /* Get the processor vendor */ - mib[0] = CTL_MACHDEP; mib[1] = CPU_CPUVENDOR; len = sizeof(vendor); if (sysctl(mib, 2, vendor, , NULL, 0) == -1)
Re: cdio: read_track: plug leak
Hi, Patch was also posted here, but I didn't test it. https://marc.info/?l=openbsd-tech=149784342025304=2 - Michael On Sun, Sep 10, 2017 at 04:23:49PM -0500, Scott Cheloha wrote: > Hi, > > Saw this when preparing the monotonic clock patch. > > This is a leak, right? Every other return path in read_track() > aside from the malloc failure frees sec. > > I think the function itself is more confusing than it needs to be > and could use a refactor but that belongs in a separate patch. > > Feedback? > > -- > Scott Cheloha > > Index: usr.bin/cdio/rip.c > === > RCS file: /cvs/src/usr.bin/cdio/rip.c,v > retrieving revision 1.16 > diff -u -p -r1.16 rip.c > --- usr.bin/cdio/rip.c20 Aug 2015 22:32:41 - 1.16 > +++ usr.bin/cdio/rip.c10 Sep 2017 21:16:51 - > @@ -398,6 +398,7 @@ read_track(struct track *ti) > } > if (ti->hdl != NULL && > (sio_write(ti->hdl, sec, blksize) == 0)) { > + free(sec); > sio_close(ti->hdl); > ti->hdl = NULL; > warnx("\nerror while writing to audio output"); >
cdio: read_track: plug leak
Hi, Saw this when preparing the monotonic clock patch. This is a leak, right? Every other return path in read_track() aside from the malloc failure frees sec. I think the function itself is more confusing than it needs to be and could use a refactor but that belongs in a separate patch. Feedback? -- Scott Cheloha Index: usr.bin/cdio/rip.c === RCS file: /cvs/src/usr.bin/cdio/rip.c,v retrieving revision 1.16 diff -u -p -r1.16 rip.c --- usr.bin/cdio/rip.c 20 Aug 2015 22:32:41 - 1.16 +++ usr.bin/cdio/rip.c 10 Sep 2017 21:16:51 - @@ -398,6 +398,7 @@ read_track(struct track *ti) } if (ti->hdl != NULL && (sio_write(ti->hdl, sec, blksize) == 0)) { + free(sec); sio_close(ti->hdl); ti->hdl = NULL; warnx("\nerror while writing to audio output");
cdio: mono clock for progress printouts in rip, write
Hi, This keeps the progress printouts from stalling in the pathological case. We were also missing for gettimeofday(2). -- Scott Cheloha Index: usr.bin/cdio/mmc.c === RCS file: /cvs/src/usr.bin/cdio/mmc.c,v retrieving revision 1.30 diff -u -p -r1.30 mmc.c --- usr.bin/cdio/mmc.c 16 Jan 2015 06:40:06 - 1.30 +++ usr.bin/cdio/mmc.c 10 Sep 2017 20:37:45 - @@ -18,6 +18,7 @@ #include #include #include +#include #include /* setbit, isset */ #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include "extern.h" @@ -433,7 +435,7 @@ writetao(struct track_head *thp) int writetrack(struct track_info *tr, int track) { - struct timeval tv, otv, atv; + struct timespec tv, otv, atv; u_char databuf[65536], nblk; u_int end_lba, lba, tmp; scsireq_t scr; @@ -451,9 +453,9 @@ writetrack(struct track_info *tr, int tr scr.senselen = SENSEBUFLEN; scr.flags = SCCMD_ESCAPE|SCCMD_WRITE; - timerclear(); + timespecclear(); atv.tv_sec = 1; - atv.tv_usec = 0; + atv.tv_nsec = 0; if (get_nwa() != SCCMD_OK) { warnx("cannot get next writable address"); @@ -500,13 +502,13 @@ again: } lba += nblk; - gettimeofday(, NULL); - if (lba == end_lba || timercmp(, , >)) { + clock_gettime(CLOCK_MONOTONIC, ); + if (lba == end_lba || timespeccmp(, , >)) { fprintf(stderr, "\rtrack %02d '%c' %08u/%08u %3d%%", track, tr->type, lba, end_lba, 100 * lba / end_lba); - timeradd(, , ); + timespecadd(, , ); } tmp = htobe32(lba); /* update lba in cdb */ memcpy([2], , sizeof(tmp)); Index: usr.bin/cdio/rip.c === RCS file: /cvs/src/usr.bin/cdio/rip.c,v retrieving revision 1.16 diff -u -p -r1.16 rip.c --- usr.bin/cdio/rip.c 20 Aug 2015 22:32:41 - 1.16 +++ usr.bin/cdio/rip.c 10 Sep 2017 20:37:45 - @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #include "extern.h" @@ -362,7 +364,7 @@ read_data_sector(u_int32_t lba, u_char * int read_track(struct track *ti) { - struct timeval tv, otv, atv; + struct timespec tv, otv, atv; u_int32_t i, blksize, n_sec; u_char *sec; int error; @@ -373,18 +375,18 @@ read_track(struct track *ti) if (sec == NULL) return (-1); - timerclear(); + timespecclear(); atv.tv_sec = 1; - atv.tv_usec = 0; + atv.tv_nsec = 0; for (i = 0; i < n_sec; ) { - gettimeofday(, NULL); - if (timercmp(, , >)) { + clock_gettime(CLOCK_MONOTONIC, ); + if (timespeccmp(, , >)) { fprintf(stderr, "\rtrack %u '%c' %08u/%08u %3u%%", ti->track, (ti->isaudio) ? 'a' : 'd', i, n_sec, 100 * i / n_sec); - timeradd(, , ); + timespecadd(, , ); } error = read_data_sector(i + ti->start_lba, sec, blksize);
md5(1): use mono clock in time trial
Hi, Use a monotonic clock for the elapsed time trial. -- Scott Cheloha Index: bin/md5/md5.c === RCS file: /cvs/src/bin/md5/md5.c,v retrieving revision 1.91 diff -u -p -r1.91 md5.c --- bin/md5/md5.c 22 May 2017 16:00:47 - 1.91 +++ bin/md5/md5.c 10 Sep 2017 19:29:05 - @@ -750,7 +750,7 @@ void digest_time(struct hash_list *hl, int times) { struct hash_function *hf; - struct timeval start, stop, res; + struct timespec start, stop, res; union ANY_CTX context; u_int i; u_char data[TEST_BLOCK_LEN]; @@ -769,14 +769,14 @@ digest_time(struct hash_list *hl, int ti for (i = 0; i < TEST_BLOCK_LEN; i++) data[i] = (u_char)(i & 0xff); - gettimeofday(, NULL); + clock_gettime(CLOCK_MONOTONIC, ); hf->init(); for (i = 0; i < count; i++) hf->update(, data, (size_t)TEST_BLOCK_LEN); digest_end(hf, , digest, sizeof(digest), hf->base64); - gettimeofday(, NULL); - timersub(, , ); - elapsed = res.tv_sec + res.tv_usec / 100.0; + clock_gettime(CLOCK_MONOTONIC, ); + timespecsub(, , ); + elapsed = res.tv_sec + res.tv_nsec / 10.0; (void)printf("\nDigest = %s\n", digest); (void)printf("Time = %f seconds\n", elapsed);
Re: [PATCH] pwd_mkdb.8 - fix wording
Hi Raf, Raf Czlonka wrote on Sat, Sep 09, 2017 at 10:03:03PM +0100: > I guess the two could be simplified further and combined into one Done, and i also fixed various other aspects while there. Yours, Ingo