-
Notifications
You must be signed in to change notification settings - Fork 241
Prefer size_t over int where possible #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1863,9 +1863,9 @@ update_script_environment(void) | |
struct userenv *uep; | ||
|
||
for (uep = userenv_list; uep != NULL; uep = uep->ue_next) { | ||
int i; | ||
size_t i; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For a case like this where the variable is a loop index rather than the size or length of something, I'd prefer plain long or unsigned long rather than size_t. Same comment applies in a few other places. |
||
char *p, *newstring; | ||
int nlen = strlen(uep->ue_name); | ||
size_t nlen = strlen(uep->ue_name); | ||
|
||
for (i = 0; (p = script_env[i]) != NULL; i++) { | ||
if (strncmp(p, uep->ue_name, nlen) == 0 && p[nlen] == '=') | ||
|
@@ -2164,7 +2164,7 @@ ppp_script_setenv(char *var, char *value, int iskey) | |
{ | ||
size_t varl = strlen(var); | ||
size_t vl = varl + strlen(value) + 2; | ||
int i; | ||
size_t i; | ||
char *p, *newstring; | ||
|
||
newstring = (char *) malloc(vl+1); | ||
|
@@ -2223,8 +2223,8 @@ ppp_script_setenv(char *var, char *value, int iskey) | |
void | ||
ppp_script_unsetenv(char *var) | ||
{ | ||
int vl = strlen(var); | ||
int i; | ||
size_t vl = strlen(var); | ||
size_t i; | ||
char *p; | ||
|
||
if (script_env == 0) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,17 @@ | |
#include <atmsap.h> | ||
|
||
|
||
int __atmlib_fetch(const char **pos,...) | ||
size_t __atmlib_fetch(const char **pos,...) | ||
{ | ||
const char *value; | ||
int ref_len,best_len,len; | ||
int i,best; | ||
size_t ref_len,best_len,len; | ||
size_t i,best; | ||
va_list ap; | ||
|
||
va_start(ap,pos); | ||
ref_len = strlen(*pos); | ||
best_len = 0; | ||
best = -1; | ||
best = 0; | ||
for (i = 0; (value = va_arg(ap,const char *)); i++) { | ||
len = strlen(value); | ||
if (*value != '!' && len <= ref_len && len > best_len && | ||
|
@@ -37,7 +37,7 @@ int __atmlib_fetch(const char **pos,...) | |
} | ||
} | ||
va_end(ap); | ||
if (best > -1) (*pos) += best_len; | ||
(*pos) += best_len; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a semantic change; previously the function would return -1 if the string at *pos didn't match any of the argument strings at all, whereas now it will return 0, which callers interpret as a match with the second argument. So now text2qos will parse things incorrectly. This is an example of why I would have preferred this commit to be split into smaller pieces, for example, four separate commits for chat, pppd, and the pppoatm and pppoe plugins. If you had, I could merge the commits that are OK. As it is, I can't merge any of it. |
||
return best; | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.