RE: [PATCH v2 12/30] cxlflash: Refine host/device attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Brian King
> Sent: 18 September 2015 22:35
...
> > +	for (i = 0; i < CXLFLASH_NUM_VLUNS; i++, buf += 22)
> 
> Rather than this bug prone hard coded 22, how about never incrementing buf and do something
> similar to this:
> 
> > +		bytes += scnprintf(buf, PAGE_SIZE, "%03d: %016llX\n",
> > +				   i, readq_be(&fc_port[i]));
> 
> 		bytes += scnprintf(&buf[bytes], PAGE_SIZE, "%03d: %016llX\n",
> 				   i, readq_be(&fc_port[i]));
...

	bytes += scnprintf(buf + bytes, PAGE_SIZE - bytes, ....

You need to check scnprintf()'s return value though.
The above is wrong for libc's snprintf().

	David

��.n��������+%������w��{.n�����{������ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux