On 04/03/2013 05:04 PM, Osier Yang wrote:
On 01/04/13 20:00, Han Cheng wrote:
> + if (virAsprintf(&tmp, SCSI_DEVFS "/%s/vendor", dev->name) < 0)
{
> + virReportOOMError();
> + goto out;
> + }
> + if (virFileReadAll(tmp, 1024, &vendor) < 0)
> + goto out;
> + VIR_FREE(tmp);
> + tmp = NULL;
> + if (virAsprintf(&tmp, SCSI_DEVFS "/%s/model", dev->name) < 0)
{
> + virReportOOMError();
> + goto out;
> + }
> + if (virFileReadAll(tmp, 1024, &model) < 0)
> + goto out;
> + *(vendor + strlen(vendor) - 1) = '\0';
This should be right after reading "vendor"
> + *(model + strlen(model) - 1) = '\0';
> + if (virAsprintf(&dev->id, "%s %s", vendor, model) < 0) {
Is it possible for the "vendor" and "name" contains white space(s)?
if
it is,
then separating them by one space has problem.
Actually, it is due to my tests which are done before sending thest
patches out.
I thought this may not be a big problem. It seems not. So we need to
virTrimSpaces to trim the spaces.