qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [Qemu-devel] [PATCH v1 1/1] hexdump: Add null guard o


From: Peter Crosthwaite
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v1 1/1] hexdump: Add null guard on output file.
Date: Sun, 3 Aug 2014 11:14:32 +1000

On Sat, Aug 2, 2014 at 11:26 PM, Michael Tokarev <address@hidden> wrote:
> 31.07.2014 04:31, Peter Crosthwaite wrote:
>> To avoid callsites with optional output having to NULL guard.
>
> Isn't it a bit backwards?  If we don't need output, maybe we should
> not call hexdump in the first place?
>

Well my thinking is a NULL File * is a good way to "don't need output"
and then it means then the multiple callsites can avoid:


if (fp) {


Note that many of the exitinst



> Thanks,
>
> /mjt
>
>> Signed-off-by: Peter Crosthwaite <address@hidden>
>> ---
>> Noting in-tree is affected by this yet, but I though I'd get this
>> out of the way straight-up rather than elongate other series.
>>
>>  util/hexdump.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/util/hexdump.c b/util/hexdump.c
>> index 969b340..b607236 100644
>> --- a/util/hexdump.c
>> +++ b/util/hexdump.c
>> @@ -19,6 +19,9 @@ void qemu_hexdump(const char *buf, FILE *fp, const char 
>> *prefix, size_t size)
>>  {
>>      unsigned int b;
>>
>> +    if (!fp) {
>> +        return;
>> +    }
>>      for (b = 0; b < size; b++) {
>>          if ((b % 16) == 0) {
>>              fprintf(fp, "%s: %04x:", prefix, b);
>>
>
>



reply via email to

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