mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-06 05:16:10 +00:00
C overhead fixes (#20402)
* [C][Client] Remove redundant casts Don't explicitly cast void pointers as it's unnecessary in C, but leave printf arguments untouched to avoid setting off -Wformat. * [C][Client] Cosmetic: remove unnecessary parens, align some lines * [C][Client] Reduce number of unnecessary strlen() calls
This commit is contained in:
@@ -26,9 +26,7 @@ UserAPI_createUser(apiClient_t *apiClient, user_t *body)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user");
|
||||
char *localVarPath = strdup("/user");
|
||||
|
||||
|
||||
|
||||
@@ -96,9 +94,7 @@ UserAPI_createUsersWithArrayInput(apiClient_t *apiClient, list_t *body)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user/createWithArray")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user/createWithArray");
|
||||
char *localVarPath = strdup("/user/createWithArray");
|
||||
|
||||
|
||||
|
||||
@@ -194,9 +190,7 @@ UserAPI_createUsersWithListInput(apiClient_t *apiClient, list_t *body)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user/createWithList")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user/createWithList");
|
||||
char *localVarPath = strdup("/user/createWithList");
|
||||
|
||||
|
||||
|
||||
@@ -294,16 +288,14 @@ UserAPI_deleteUser(apiClient_t *apiClient, char *username)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user/{username}")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user/{username}");
|
||||
char *localVarPath = strdup("/user/{username}");
|
||||
|
||||
if(!username)
|
||||
goto end;
|
||||
|
||||
|
||||
// Path Params
|
||||
long sizeOfPathParams_username = strlen(username)+3 + strlen("{ username }");
|
||||
long sizeOfPathParams_username = strlen(username)+3 + sizeof("{ username }") - 1;
|
||||
if(username == NULL) {
|
||||
goto end;
|
||||
}
|
||||
@@ -366,16 +358,14 @@ UserAPI_getUserByName(apiClient_t *apiClient, char *username)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user/{username}")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user/{username}");
|
||||
char *localVarPath = strdup("/user/{username}");
|
||||
|
||||
if(!username)
|
||||
goto end;
|
||||
|
||||
|
||||
// Path Params
|
||||
long sizeOfPathParams_username = strlen(username)+3 + strlen("{ username }");
|
||||
long sizeOfPathParams_username = strlen(username)+3 + sizeof("{ username }") - 1;
|
||||
if(username == NULL) {
|
||||
goto end;
|
||||
}
|
||||
@@ -458,9 +448,7 @@ UserAPI_loginUser(apiClient_t *apiClient, char *username, char *password)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user/login")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user/login");
|
||||
char *localVarPath = strdup("/user/login");
|
||||
|
||||
|
||||
|
||||
@@ -574,9 +562,7 @@ UserAPI_logoutUser(apiClient_t *apiClient)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user/logout")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user/logout");
|
||||
char *localVarPath = strdup("/user/logout");
|
||||
|
||||
|
||||
|
||||
@@ -631,9 +617,7 @@ UserAPI_testIntAndBool(apiClient_t *apiClient, int *keep, int *keepDay)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user/testIntAndBool")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user/testIntAndBool");
|
||||
char *localVarPath = strdup("/user/testIntAndBool");
|
||||
|
||||
|
||||
|
||||
@@ -714,16 +698,14 @@ UserAPI_updateUser(apiClient_t *apiClient, char *username, user_t *body)
|
||||
apiClient->response_code = 0;
|
||||
|
||||
// create the path
|
||||
long sizeOfPath = strlen("/user/{username}")+1;
|
||||
char *localVarPath = malloc(sizeOfPath);
|
||||
snprintf(localVarPath, sizeOfPath, "/user/{username}");
|
||||
char *localVarPath = strdup("/user/{username}");
|
||||
|
||||
if(!username)
|
||||
goto end;
|
||||
|
||||
|
||||
// Path Params
|
||||
long sizeOfPathParams_username = strlen(username)+3 + strlen("{ username }");
|
||||
long sizeOfPathParams_username = strlen(username)+3 + sizeof("{ username }") - 1;
|
||||
if(username == NULL) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user