|
| From: | Avi Kivity |
| Subject: | Re: [Qemu-devel] [PATCH 8/9] lsi53c895a: avoid a warning from clang analyzer |
| Date: | Mon, 05 Sep 2011 08:35:24 +0300 |
| User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
On 09/04/2011 07:27 PM, Blue Swirl wrote:
>> to be really necessary). So let's simply clear all queued
>> commands for the current device: */
>> - id = current_tag& 0x0000ff00;
>> - QTAILQ_FOREACH_SAFE(p,&s->queue, next, p_next) {
>> - if ((p->tag& 0x0000ff00) == id) {
>> - scsi_req_cancel(p->req);
>> + {
>> + int id;
>> +
>> + id = current_tag& 0x0000ff00;
>> + QTAILQ_FOREACH_SAFE(p,&s->queue, next, p_next) {
>> + if ((p->tag& 0x0000ff00) == id) {
>> + scsi_req_cancel(p->req);
>> + }
>> }
>> }
>>
>
> Why not keep id declared in the outer scope? This extra indentation is
> annoying.
Also the variable could be dropped altogether simply with:
if ((p->tag& 0x0000ff00) == (current_tag& 0x0000ff00)) {
I have no preference.
Yet another option is to allow intermixing declarations and statements (which C99 allows), though it tends to get some traditionalists worked up.
It's particularly nice in for () loops. -- I have a truly marvellous patch that fixes the bug which this signature is too narrow to contain.
| [Prev in Thread] | Current Thread | [Next in Thread] |