qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] 80-column rule and breaking output statements


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] 80-column rule and breaking output statements
Date: Sat, 2 Jul 2011 09:38:30 +0100

On Fri, Jul 1, 2011 at 8:43 PM, Blue Swirl <address@hidden> wrote:
> On Mon, Jun 27, 2011 at 12:48 PM, Amit Shah <address@hidden> wrote:
>> On (Sun) 26 Jun 2011 [20:43:16], Blue Swirl wrote:
>>> On Wed, Jun 22, 2011 at 7:53 AM, Amit Shah <address@hidden> wrote:
>>
>> [snip]
>>
>>> > From dec93d9eccd639f7bfd1343dca65fa112eb19e3e Mon Sep 17 00:00:00 2001
>>> > Message-Id: <address@hidden>
>>> > From: Amit Shah <address@hidden>
>>> > Date: Wed, 22 Jun 2011 10:20:48 +0530
>>> > Subject: [PATCH 1/1] CODING_STYLE: Add exception for log output 80-char 
>>> > limit
>>> >
>>> > Output that's logged can be beyond 80 chars to preserve sane grepping.
>>>
>>> Nack. Grepping (why just logs?) is just one use case. There are other
>>
>> I'm not talking about grepping logs.  I'm talking about grepping code
>> once you have something in the logs.  With line breaks in the code but
>> not in the log, you will not get the desired result.
>>
>> Example:
>>
>>
>> fprintf("This is a line ");
>> fprintf("broken in two code lines\n");
>>
>>
>> Output is:
>>
>> This is a line broken in two code lines
>>
>>
>> Picking that line from the output and grepping for it in the source
>> doesn't get you what you want.
>
> Nack. Grep would not match for example
> fprintf("'%s' invalid media\n", s);
> unless you know how to grep only for some parts of the error string
> and in that case splitting the line would not hurt very much anymore.
>
> If you want robust grepping, each error message should contain an ID,
> for example:
> fprintf("ERROR-ID-0015:'%s' invalid media\n", s);
>
> Then grepping would work even for
> fprintf(
> "ERROR-ID-0015:"
> "'%s'"
> " invalid"
> " media\n",
> s);

I don't see split lines as an issue because I never grep for an entire
line.  Pick a small, unique, fixed part of the message and you'll find
it.

"Small" in order to avoid any formatting or split line issues.
"Unique" in order to cut down the number of grep results.
"Fixed" in order to avoid format string expansions as Blue Swirl mentioned.

Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]