[Toybox] [TOY] lspci

Felix Janda felix.janda at posteo.de
Sat Jul 27 00:56:53 PDT 2013


Rob Landley wrote:
> On 07/22/2013 02:05:26 PM, Felix Janda wrote:
> > > 75 lines total.
> > 
> > Down to 70 after application of the below patch with small fixes.
> > 
> > It felt more sensible to me to read 2 more bytes and ignore them than  
> > to
> > seek for 2 bytes in a file. So preadat_name now has one argument less.
> > 
> > Use calloc instead of malloc + memset. With this also the off-by-one
> > error from (origninally) line 32 is fixed. It would be nice to use
> > toybuf for this, wouldn't it? That would also make valgrind happier.
> > 
> > Print "" instead of "." when .../driver is missing.
> > 
> > The only difference between the usual output and the machine readable
> > output is the format string. Use this to avoid some repetition.
> > 
> > Felix
> 
> patching file toys/pending/lspci.c
> Hunk #2 FAILED at 32.
> Hunk #3 succeeded at 65 (offset 1 line).
> 1 out of 3 hunks FAILED -- saving rejects to file  
> toys/pending/lspci.c.rej
> 
> Did I miss an intermediate patch? Could you send me a fresh one that  
> applies to my current tree?

In the current tree I see that you have applied a newer version anyway.
(with some minor cleanup of yours.)

Unfortunately that version has "lspci -e" broken as observed by Isaac
somewhere in this thread. Below is a fix. (One could also replace the
"!=" by "==".)

Anyway Isaac is doing (or planning to do) a major rewrite enabling lspci
to read the pciid database for human readable names of vendors and devices.

Felix

# HG changeset patch
# User Felix Janda <felix.janda at posteo.de>
# Date 1374911140 -7200
# Node ID cb4e84875a30cca9aed3fa613624cd94e7e17d87
# Parent  e33f0312de6e3c57784afd82a12b22fc20702656
Fix lspci -e

diff -r e33f0312de6e -r cb4e84875a30 toys/pending/lspci.c
--- a/toys/pending/lspci.c	Sat Jul 27 00:50:29 2013 -0500
+++ b/toys/pending/lspci.c	Sat Jul 27 09:45:40 2013 +0200
@@ -36,7 +36,7 @@
       int fd, size;
 
       if ((fd = openat(dirfd, *fields, O_RDONLY)) < 0) continue;
-      size = 6 + 2*((toys.optflags & FLAG_e) && (p != toybuf));
+      size = ((toys.optflags & FLAG_e) && (p == toybuf)) ? 8 : 6;
       p[read(fd, p, size)] = '\0';
       close(fd);
     }

 1374911813.0


More information about the Toybox mailing list