Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Martin Mares <mj@ucw.cz>
To: "Dr. David Alan Gilbert" <dave@treblig.org>
Cc: linux-pci@vger.kernel.org
Subject: Re: pciutils pci_open seg with invalid arg to -i
Date: Thu, 6 Dec 2012 17:08:27 +0100	[thread overview]
Message-ID: <mj+md-20121206.160703.2718.nikam@ucw.cz> (raw)
In-Reply-To: <20121204142008.GB6117@gallifrey>

Hi!

> So I was going to suggest something like:
> 
>  33   if (len < 3 || memcmp(a->id_file_name + len - 3, ".gz", 3) != 0)
>  34     return result;

Yes, that's right.

Please try the current version in the Git repository, it's fixed there.

> which would mean that it would drop out if it was a short filename; but
> then I started to try and understand the code more; it looks to me like:
> 
>    try and gzopen it.
>    if that fails
>      check it ended with a .gz (else fail)
>      strip the .gz off the end
>      gzopen it without the .gz
> 
> But why bother?  According to the zlib manual for gzopen :
>   ( http://www.zlib.net/manual.html )
>      
> ' gzopen can be used to read a file which is not in gzip format; in this case
> gzread will directly read from the file without decompression. When reading,
> this will be detected automatically by looking for the magic two-byte gzip
> header. '
> 
> So what are lines 32-39 trying to do?

When somebody specifies a file name like "pci.ids.gz" (or it's the default name)
and no such file exists, it tries the same name without ".gz".

				Have a nice fortnight
-- 
Martin `MJ' Mares                          <mj@ucw.cz>   http://mj.ucw.cz/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
Weather forecast for tonight: dark.

      parent reply	other threads:[~2012-12-06 16:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-04 14:20 pciutils pci_open seg with invalid arg to -i Dr. David Alan Gilbert
2012-12-05 20:36 ` Martin Mares
2012-12-06 16:08 ` Martin Mares [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mj+md-20121206.160703.2718.nikam@ucw.cz \
    --to=mj@ucw.cz \
    --cc=dave@treblig.org \
    --cc=linux-pci@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox