Remove unused code. Ensure null termination after strncpy in opennebula

This commit is contained in:
Daniel P. Berrange 2009-07-01 10:40:12 +00:00
parent 1476b6d487
commit 69ba4d0971
3 changed files with 11 additions and 46 deletions

View File

@ -1,3 +1,8 @@
Wed Jul 1 11:38:15 BST 2009 Daniel P. Berrange <berrange@redhat.com>
* src/opennebula/one_client.c, src/opennebula/one_client.h:
Remove unused code. Ensure null termination after strncpy
Wed Jul 1 10:21:15 CEST 2009 Daniel Veillard <veillard@redhat.com>
* src/storage_driver.c: don't destroy a pool when calling create

View File

@ -33,16 +33,9 @@ void c_oneStart()
xmlrpc_client_init2(&one_client.env, XMLRPC_CLIENT_NO_FLAGS,
"OpenNebula API Client", "1.2", NULL, 0);
one_client.error=0;
#ifdef ONED_PORT
one_client.url=(char *)malloc(64);
snprintf(one_client.url, 63, "http://localhost:%d/RPC2", ONED_PORT);
#else
one_client.url=(char *)"http://localhost:2633/RPC2";
#endif
one_client.session=(char *)"one-session";
one_client.error = 0;
one_client.url = "http://localhost:2633/RPC2";
one_client.session = "one-session";
};
@ -94,35 +87,6 @@ int c_oneMigrate(int vmid, int hid, int flag)
return c_oneReturnCode(resultP);
}
int c_oneAllocate(char* template_file)
{
int file;
int size;
int bytes_read;
char *file_text;
int return_code;
file=open(template_file, O_RDONLY);
size=lseek(file, 0, SEEK_END);
lseek(file, 0, SEEK_SET);
file_text=(char *)malloc(size+1);
bytes_read=read(file, file_text, size);
close(file);
if(bytes_read==size) {
file_text[size]=0;
return_code=c_oneAllocateTemplate(file_text);
free(file_text);
return return_code;
} else {
free(file_text);
return -1;
}
}
int c_oneAllocateTemplate(char* vm_template)
{
xmlrpc_value *resultP;
@ -222,6 +186,7 @@ int c_oneVmInfo(int vmid, char* ret_info,int length)
if( return_code )
{
strncpy(ret_info, return_string, length-1);
ret_info[length-1] = '\0';
xmlrpc_DECREF(resultP);
free(return_string);
@ -241,9 +206,6 @@ void c_oneFree()
{
xmlrpc_env_clean(&one_client.env);
xmlrpc_client_cleanup();
#ifdef ONE_PORT
free(one_client.url);
#endif
}

View File

@ -24,8 +24,8 @@
struct _oneClient {
xmlrpc_env env;
char *url;
char *session;
const char *url;
const char *session;
char *error;
};
@ -38,8 +38,6 @@ int c_oneDeploy(int vmid, int hid);
int c_oneMigrate(int vmid, int hid, int flag);
int c_oneAllocate(char* template_file);
int c_oneAllocateTemplate(char* vm_template);
int c_oneAction(int vmid,char* action);