From 69ba4d0971d762c05b5817a3239d929d1907a819 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Wed, 1 Jul 2009 10:40:12 +0000 Subject: [PATCH] Remove unused code. Ensure null termination after strncpy in opennebula --- ChangeLog | 5 ++++ src/opennebula/one_client.c | 46 ++++--------------------------------- src/opennebula/one_client.h | 6 ++--- 3 files changed, 11 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc474f3e8a..c6444e4b63 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Jul 1 11:38:15 BST 2009 Daniel P. Berrange + + * 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 * src/storage_driver.c: don't destroy a pool when calling create diff --git a/src/opennebula/one_client.c b/src/opennebula/one_client.c index 6d0fc6ce81..abc42f9540 100644 --- a/src/opennebula/one_client.c +++ b/src/opennebula/one_client.c @@ -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 } diff --git a/src/opennebula/one_client.h b/src/opennebula/one_client.h index 238d1a616e..05dd3792a2 100644 --- a/src/opennebula/one_client.h +++ b/src/opennebula/one_client.h @@ -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); -- GitLab