All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Rajnoha <prajnoha@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 1/4] report: Print NULL strings as "" in _string_disp (instead of a SEGV).
Date: Tue, 16 Dec 2014 10:56:05 +0100	[thread overview]
Message-ID: <549001B5.6010508@redhat.com> (raw)
In-Reply-To: <548FF96A.4020706@redhat.com>

On 12/16/2014 10:20 AM, Peter Rajnoha wrote:
> On 12/15/2014 11:32 PM, Petr Rockai wrote:
>> ---
>>  lib/report/report.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/lib/report/report.c b/lib/report/report.c
>> index 5637d50..043de88 100644
>> --- a/lib/report/report.c
>> +++ b/lib/report/report.c
>> @@ -179,6 +179,8 @@ static int _string_disp(struct dm_report *rh, struct dm_pool *mem __attribute__(
>>  			struct dm_report_field *field,
>>  			const void *data, void *private __attribute__((unused)))
>>  {
>> +	if (!*(void**) data)
>> +		return _field_set_value(field, "", NULL);
>>  	return dm_report_field_string(rh, field, (const char * const *) data);
>>  }
> 
> ...we could do this, but I think more appropriate here would be to
> define field-specific reserved value to represent the "undefined"
> value so we can match against this too when using selection
> (-S|--select).
> 
> So, in lib/report/values.h, you can just define:
> 
> FIELD_RESERVED_VALUE(cache_policy, cache_policy_undefined, "", "", "undefined", ... add as many synonym to "undefined" here as you need ...)
> 

Thinking about this more, we have actually three situations to display
(correct me if I'm wrong please).

So in the end, we need:

 - if cache LV and NULL policy -> we should report "default" (or similar keyword to denote "default" policy used)
 - if cache LV and non-NULL policy -> we should report the policy name directly
 - if non-cache LV (which has always the policy NULL, if course) -> we should report "" (with "undefined", "undef" ... synonyms to match against in selection criteria)

-- 
Peter



      reply	other threads:[~2014-12-16  9:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-15 22:32 [PATCH 1/4] report: Print NULL strings as "" in _string_disp (instead of a SEGV) Petr Rockai
2014-12-15 22:32 ` [PATCH 2/4] report: Add cache_policy and cache_settings (LV) segment fields Petr Rockai
2014-12-15 22:32 ` [PATCH 3/4] test: Add a test for reports of cache policy & settings Petr Rockai
2014-12-15 22:32 ` [PATCH 4/4] test: Check that cache settings properly survive LV reactivation Petr Rockai
2014-12-16  9:20 ` [PATCH 1/4] report: Print NULL strings as "" in _string_disp (instead of a SEGV) Peter Rajnoha
2014-12-16  9:56   ` Peter Rajnoha [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=549001B5.6010508@redhat.com \
    --to=prajnoha@redhat.com \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.