Opened 8 months ago

Closed 7 months ago

#26282 closed defect (implemented)

Smartlist index implicitly converted to int

Reported by: rl1987 Owned by: rl1987
Priority: Medium Milestone: Tor: 0.3.5.x-final
Component: Core Tor/Tor Version: Tor: unspecified
Severity: Normal Keywords:
Cc: catalyst Actual Points:
Parent ID: #26196 Points:
Reviewer: ahf Sponsor:

Description

When building with DEBUG_SMARTLIST:

src/common/util.c:4816:45: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    const char *s = smartlist_get(env_vars, i);
                    ~~~~~~~~~~~~~           ^
src/common/util.c:4846:54: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
      const char *s = smartlist_get(env_vars_sorted, i);
                      ~~~~~~~~~~~~~                  ^
2 warnings generated.
src/common/util.c:4816:45: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    const char *s = smartlist_get(env_vars, i);
                    ~~~~~~~~~~~~~           ^
src/common/util.c:4846:54: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
      const char *s = smartlist_get(env_vars_sorted, i);
                      ~~~~~~~~~~~~~                  ^
2 warnings generated.
src/or/control.c:4627:43: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    const char *arg = smartlist_get(args, i);
                      ~~~~~~~~~~~~~       ^
1 warning generated.
src/or/geoip.c:153:57: warning: implicit conversion loses integer precision: 'intptr_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
    geoip_country_t *c = smartlist_get(geoip_countries, idx);
                         ~~~~~~~~~~~~~                  ^~~
1 warning generated.
src/or/control.c:4627:43: warning: implicit conversion loses integer precision: 'size_t' (aka 'unsigned long') to 'int' [-Wshorten-64-to-32]
    const char *arg = smartlist_get(args, i);
                      ~~~~~~~~~~~~~       ^
1 warning generated.
src/or/geoip.c:153:57: warning: implicit conversion loses integer precision: 'intptr_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
    geoip_country_t *c = smartlist_get(geoip_countries, idx);
                         ~~~~~~~~~~~~~                  ^~~
1 warning generated.

Child Tickets

Change History (5)

comment:1 Changed 8 months ago by rl1987

Owner: set to rl1987
Status: newaccepted

comment:2 Changed 8 months ago by rl1987

Status: acceptedneeds_review

comment:3 Changed 7 months ago by dgoulet

Reviewer: ahf

comment:4 Changed 7 months ago by ahf

Status: needs_reviewmerge_ready

Patch looks good to me.

I think it could make sense to switch the idx fields to be an unsigned type, but I think that would probably generate even more warnings in these smartlist debug builds, so I think this patch is good as it is.

comment:5 Changed 7 months ago by nickm

Resolution: implemented
Status: merge_readyclosed

Merged it!

Note: See TracTickets for help on using tickets.