From: Karel Zak <kzak@redhat.com>
To: Davidlohr Bueso <dave@gnu.org>
Cc: Petr Uzel <petr.uzel@suse.cz>, util-linux <util-linux@vger.kernel.org>
Subject: Re: [PATCH 03/10] fdisk: API: add fdisk_label_change
Date: Tue, 24 Jul 2012 13:35:57 +0200 [thread overview]
Message-ID: <20120724113557.GC7057@x2.net.home> (raw)
In-Reply-To: <1342976704.2863.13.camel@offbook>
On Sun, Jul 22, 2012 at 07:05:04PM +0200, Davidlohr Bueso wrote:
> 5 files changed, 43 insertions(+), 0 deletions(-)
Not applied, it seems unnecessary.
I have temporary added fdisk_create_default_disklabel, but the final
code (the current master) contains your fdisk_create_disklabel()
where NULL name means a default disk label.
I have renamed many functions :-) It seems better to use
fdisk_create_disklabel() than fdisk_label_create()
fdisk_add_partition() than fdisk_label_partition_new()
.. etc.
> + /* not really changing the label */
> + if (!strncmp(name, cxt->label->name, strlen(name)))
> + goto done;
BTW, I don't see a problem with strings -- very probably we will use
strings in user interface, and add extra layer to translate strings
to IDs seems like unnecessary optimization and complexity.
> + for (i = 0; i < ARRAY_SIZE(labels); i++) {
> + if (strncmp(name, labels[i]->name, strlen(name)))
> + continue;
> +
> + /* found the new label */
> + memset(cxt->label, 0, sizeof(struct fdisk_label));
> + memcpy(cxt->label, labels[i], sizeof(struct fdisk_label));
> + DBG(LABEL, dbgprint("changing to a %s label\n", labels[i]->name));
> + goto done;
> + }
Oh no, let's use labels[] as constant array and cxt->label as
const struct pointer. The list of functions does not have to
be modifiable, and
cxt->label = labels[i];
is definitely better than memcpy().
Note that it's will probably necessary to add
void *labeldata;
to fdisk_context for label private data. (For example to kill
MBRbuffer_changed or another DOS specific global variables.)
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
prev parent reply other threads:[~2012-07-24 11:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-22 17:05 [PATCH 03/10] fdisk: API: add fdisk_label_change Davidlohr Bueso
2012-07-24 9:47 ` Bernhard Voelker
2012-07-24 9:56 ` Petr Uzel
2012-07-24 10:32 ` Bernhard Voelker
2012-07-24 10:39 ` Davidlohr Bueso
2012-07-24 10:42 ` Petr Uzel
2012-07-24 10:47 ` Bernhard Voelker
2012-07-24 9:52 ` Petr Uzel
2012-07-24 10:41 ` Davidlohr Bueso
2012-07-24 10:52 ` Petr Uzel
2012-07-24 11:35 ` Karel Zak [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=20120724113557.GC7057@x2.net.home \
--to=kzak@redhat.com \
--cc=dave@gnu.org \
--cc=petr.uzel@suse.cz \
--cc=util-linux@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).