Bharata B Rao <bhar...@linux.vnet.ibm.com> writes: > From: Bharata B Rao <bhar...@linux.vnet.ibm.com> > > Make inet_parse() non static. > > - Make inet_parse() non-static so that other subsystems like gluster > can use it to parse inet addresses. As a pre-requisite, define and > globalize the qemu_inet_opts.
Please repost this as part of a series that needs non-static inet_parse(). I'm worried parameter "block" will cause trouble, but I can't see that without the users. > - Extend inet_parse() to parse just 'address' also in addition to > 'address:port'. Separate patch, please. > Signed-off-by: Bharata B Rao <bhar...@linux.vnet.ibm.com> > --- > Ideally I needn't use sscanf twice once for parsing host:port (checking > return value of 2) and if that fails for parsing host w/o port (checking > return value of 1). I could just check if sscanf returned 2 or 1 and decide > if addr:port or just addr was provided, but in the latter case the > pointer to the bytes consumed (&pos) doesn't get updated. You can use two of them, like this: a_end = b_end = -1; sscanf(str, "%d%n:%d%n", &a, &a_end, &b, &b_end); if (b_end >= 0) ... [...]