Janitor project to convert sizeof to ARRAY_LEN macro.

(closes issue #13002)
Reported by: caio1982
Patches:
      janitor_arraylen5.diff uploaded by caio1982 (license 22)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@129045 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Brett Bryant
2008-07-08 16:40:28 +00:00
parent 2ed6cea551
commit d185405755
19 changed files with 77 additions and 70 deletions

View File

@@ -66,7 +66,7 @@ static struct limits {
static int str2limit(const char *string)
{
size_t i;
for (i = 0; i < sizeof(limits) / sizeof(limits[0]); i++) {
for (i = 0; i < ARRAY_LEN(limits); i++) {
if (!strcasecmp(string, limits[i].limit))
return limits[i].resource;
}
@@ -76,7 +76,7 @@ static int str2limit(const char *string)
static const char *str2desc(const char *string)
{
size_t i;
for (i = 0; i < sizeof(limits) / sizeof(limits[0]); i++) {
for (i = 0; i < ARRAY_LEN(limits); i++) {
if (!strcmp(string, limits[i].limit))
return limits[i].desc;
}
@@ -90,7 +90,7 @@ static char *complete_ulimit(struct ast_cli_args *a)
if (a->pos > 1)
return NULL;
for (i = 0; i < sizeof(limits) / sizeof(limits[0]); i++) {
for (i = 0; i < ARRAY_LEN(limits); i++) {
if (!strncasecmp(limits[i].limit, a->word, wordlen)) {
if (++which > a->n)
return ast_strdup(limits[i].limit);
@@ -154,7 +154,7 @@ static char *handle_cli_ulimit(struct ast_cli_entry *e, int cmd, struct ast_cli_
if (a->argc == 1) {
char arg2[3];
char *newargv[2] = { "ulimit", arg2 };
for (resource = 0; resource < sizeof(limits) / sizeof(limits[0]); resource++) {
for (resource = 0; resource < ARRAY_LEN(limits); resource++) {
struct ast_cli_args newArgs = { .argv = newargv, .argc = 2 };
ast_copy_string(arg2, limits[resource].limit, sizeof(arg2));
handle_cli_ulimit(e, CLI_HANDLER, &newArgs);