Merge lp:~linuxjedi/drizzle/usability-cli-port into lp:~drizzle-trunk/drizzle/development

Proposed by Andrew Hutchings
Status: Merged
Merged at revision: not available
Proposed branch: lp:~linuxjedi/drizzle/usability-cli-port
Merge into: lp:~drizzle-trunk/drizzle/development
To merge this branch: bzr merge lp:~linuxjedi/drizzle/usability-cli-port
Reviewer Review Type Date Requested Status
Jay Pipes (community) none Approve
Drizzle Developers Pending
Review via email: mp+2366@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

This contains the -p means port not password fix with error when alpha characters are passed to it.

This also contains a few clean-ups to drizzle.cc

Note: it does not exit upon error yet due to bug #308381.

Revision history for this message
Jay Pipes (jaypipes) wrote :

Mostly great stuff, Andrew.

However, one thing should be done. Line 1571:

opt_drizzle_port= strtol(argument, &endchar, 10);

This should be changed to strtoi(), since opt_drizzle_port is defined as an int.

However, deeper than than, opt_drizzle_port should be defined as uint32_t, as it is needed in calls to drizzle_connect(), which expect a uint32_t.

So, please change line 1571 to:

opt_drizzle_port= (uint32_t) strtoi(argument, &endchar, 10);

and changed the declaration of opt_drizzle_port to be uint32_t

Other than that, looks good.

j

review: Needs Fixing (none)
Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

One slight problem, there is no strtoi. Only strtol, stroll, stroull or strtoul (and a couple to deal with floats.

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

ok, I can see a few solutions to this:

1. Update the socket code to use uint64_t
2. Iterate through the argument with isdigit() and then use atoi()
3. Use a temporary uint64_t to get the strtoul() result, check its <= 65535 and generate an error if higher than this (maximum port number). If it is <= 65535 then cast as uint32_t.

I prefer option 3 but am open to suggestions.

678. By Andrew Hutchings <linuxjedi@linuxjedi-laptop>

Merge with trunk

679. By Andrew Hutchings <linuxjedi@linuxjedi-laptop>

Fix long to uint32_t type casting problem

680. By Andrew Hutchings <linuxjedi@linuxjedi-laptop>

Merge with trunk

Revision history for this message
Andrew Hutchings (linuxjedi) wrote :

I have coded option 3 and pushed it as revision 679 of this branch.

681. By Andrew Hutchings <linuxjedi@linuxjedi-laptop>

Fail is user gives port 0 as well

682. By Andrew Hutchings <linuxjedi@linuxjedi-laptop>

Merge with trunk

Revision history for this message
Jay Pipes (jaypipes) wrote :

Looks good now. Recommend merging this in.

review: Approve (none)