Skip to content

Conversation

@jnpkrn
Copy link

@jnpkrn jnpkrn commented Feb 17, 2016

No description provided.

@jnpkrn jnpkrn force-pushed the maint-cleanup branch 2 times, most recently from 25311e6 to 7f50b96 Compare February 17, 2016 18:05
@jnpkrn
Copy link
Author

jnpkrn commented Feb 22, 2016

Related question, was there significant reason to use unsigned char
specifically? The issue is that string functions use unqualified char
(whether it is signed or not is implementation specific, moreover
typeof((char) 'c') != typeof((unsigned char) 'c') on major platforms)
hence the combination with variables derived from unsigned char makes
the compilers complain a lot.

Any objections against dropping unsigned qualifiers in this context?

@dmuhamedagic
Copy link

On Mon, Feb 22, 2016 at 06:40:15AM -0800, Jan Pokorný wrote:

Related question, was there significant reason to use unsigned char
specifically?

Where?

@jnpkrn
Copy link
Author

jnpkrn commented Feb 22, 2016

For instance:

src/config.c:912:int find_site_by_name(unsigned char *site, struct booth_site **node, int any_type)
src/booth.h:80:typedef unsigned char boothc_site  [BOOTH_NAME_LEN];
src/booth.h:81:typedef unsigned char boothc_ticket[BOOTH_NAME_LEN];
src/booth.h:82:typedef unsigned char boothc_attr[BOOTH_NAME_LEN];
src/booth.h:83:typedef unsigned char boothc_attr_value[BOOTH_ATTRVAL_LEN];

Then, e.g.,

config.c: In function ‘add_ticket’:
config.c:229:9: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
  strcpy(tk->name, name);
         ^

@dmuhamedagic
Copy link

On Mon, Feb 22, 2016 at 06:48:56AM -0800, Jan Pokorný wrote:

For instance:

src/config.c:912:int find_site_by_name(unsigned char *site, struct booth_site **node, int any_type)
src/booth.h:80:typedef unsigned char boothc_site  [BOOTH_NAME_LEN];
src/booth.h:81:typedef unsigned char boothc_ticket[BOOTH_NAME_LEN];
src/booth.h:82:typedef unsigned char boothc_attr[BOOTH_NAME_LEN];
src/booth.h:83:typedef unsigned char boothc_attr_value[BOOTH_ATTRVAL_LEN];

Then, e.g.,

config.c: In function ‘add_ticket’:
config.c:229:9: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
  strcpy(tk->name, name);
         ^

OK. I assume that you mean using 'unsigned char' in general,
right? I suppose that we can use 'char' instead, at least for
string types of the kind you quoted above. Care to take care of
it too?

@jnpkrn
Copy link
Author

jnpkrn commented Feb 22, 2016

On 22/02/16 06:52 -0800, Dejan Muhamedagic wrote:

On Mon, Feb 22, 2016 at 06:48:56AM -0800, Jan Pokorný wrote:

For instance:

src/config.c:912:int find_site_by_name(unsigned char *site, struct booth_site **node, int any_type)
src/booth.h:80:typedef unsigned char boothc_site  [BOOTH_NAME_LEN];
src/booth.h:81:typedef unsigned char boothc_ticket[BOOTH_NAME_LEN];
src/booth.h:82:typedef unsigned char boothc_attr[BOOTH_NAME_LEN];
src/booth.h:83:typedef unsigned char boothc_attr_value[BOOTH_ATTRVAL_LEN];

Then, e.g.,

config.c: In function ‘add_ticket’:
config.c:229:9: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
  strcpy(tk->name, name);
         ^

OK. I assume that you mean using 'unsigned char' in general,
right?

Yep (didn't want the description to get too hairy).

I suppose that we can use 'char' instead, at least for string types
of the kind you quoted above. Care to take care of it too?

Will do. The only cases that would matter is when such char is promoted
to int and used in the arithmetics, so I will double check.

Jan (Poki)

@dmuhamedagic
Copy link

On Mon, Feb 22, 2016 at 07:01:38AM -0800, Jan Pokorný wrote:

On 22/02/16 06:52 -0800, Dejan Muhamedagic wrote:

On Mon, Feb 22, 2016 at 06:48:56AM -0800, Jan Pokorný wrote:

For instance:

src/config.c:912:int find_site_by_name(unsigned char *site, struct booth_site **node, int any_type)
src/booth.h:80:typedef unsigned char boothc_site  [BOOTH_NAME_LEN];
src/booth.h:81:typedef unsigned char boothc_ticket[BOOTH_NAME_LEN];
src/booth.h:82:typedef unsigned char boothc_attr[BOOTH_NAME_LEN];
src/booth.h:83:typedef unsigned char boothc_attr_value[BOOTH_ATTRVAL_LEN];

Then, e.g.,

config.c: In function ‘add_ticket’:
config.c:229:9: warning: pointer targets in passing argument 1 of ‘strcpy’ differ in signedness [-Wpointer-sign]
  strcpy(tk->name, name);
         ^

OK. I assume that you mean using 'unsigned char' in general,
right?

Yep (didn't want the description to get too hairy).

I suppose that we can use 'char' instead, at least for string types
of the kind you quoted above. Care to take care of it too?

Will do. The only cases that would matter is when such char is promoted
to int and used in the arithmetics, so I will double check.

I couldn't find any such case, but please check. Thanks!

@jnpkrn
Copy link
Author

jnpkrn commented Apr 5, 2016

@dmuhamedagic Can I start rehashing this PR with respect to your objections?

@dmuhamedagic
Copy link

dmuhamedagic commented Apr 5, 2016 via email

jnpkrn added 15 commits April 11, 2016 23:02
Note that, furthermore, cl_log is not in "libgpl" (namesake does exist,
though: Game Programming Library), but rather in "libplumb" that is
currently referenced in src/Makefile.am directly, anyway.
...as this is the only reference configure script uses.

References:
http://rpm.org/gitweb?p=rpm.git;a=commit;h=6c4b0fc (~2007)
Some cases might have still been omitted.
Or more frankly, where compiler complains (which is a good
approximation) + human spotted eligible parts.

Also make cast from/to "xmlChar *" explicit.
@jnpkrn
Copy link
Author

jnpkrn commented Apr 11, 2016

So currently I offer a new round for the pull with the following changes:

Or more frankly, where compiler complains, which is a good
approximation.
if (!notime)
get_time(&a->update_ts);

assert(strnlen(name, BOOTH_NAME_LEN) < BOOTH_NAME_LEN);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather have booth continue to run, even with a truncated attribute name. iirc, this was not unpremeditated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I understand that it might be too easy (accidentally or not) to push booth layer out of the function with a single crafted geo attribute in CIB/crm_ticket one-liner. So does turning that into warning sounds better? Then, we should likely warn also in case of trying to set/delete such a troublesome (too long in either name or value) attribute being provided by the user to geostore command.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Tue, Apr 19, 2016 at 06:26:49AM -0700, Jan Pokorný wrote:

@@ -274,8 +277,9 @@ int store_geo_attr(struct ticket_config *tk, const char *name, char *val, int no
if (!notime)
get_time(&a->update_ts);

  • assert(strnlen(name, BOOTH_NAME_LEN) < BOOTH_NAME_LEN);

OK, I understand that it might be too easy (accidentally or not) to push booth layer out of the function with a single crafted geo attribute in CIB/crm_ticket one-liner. So does turning that into warning sounds better? Then, we should likely warn also in case of trying to set/delete such a troublesome (too long in either name or value) attribute being provided by the user to geostore command.

Yes, warning seems to be better.

@jnpkrn
Copy link
Author

jnpkrn commented Apr 22, 2016

Let's close this monolithic PR in favor of split PRs: #28, #29, #30
(should preferably be pulled in-order).
These PRs reflect the discussion so far.

@jnpkrn jnpkrn closed this Apr 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants