This patch removes a bunch of unused Open Nebula code which has a number of flaws. It also fixes handling of a strncpy() call to ensure there is a NULL terminator in the copied string. And finally it makes a couple of strings be 'const' since they're never changed Daniel Index: src/opennebula/one_client.c =================================================================== RCS file: /data/cvs/libvirt/src/opennebula/one_client.c,v retrieving revision 1.1 diff -u -p -r1.1 one_client.c --- src/opennebula/one_client.c 24 Jun 2009 17:32:56 -0000 1.1 +++ src/opennebula/one_client.c 30 Jun 2009 11:05:12 -0000 @@ -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 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 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 } Index: src/opennebula/one_client.h =================================================================== RCS file: /data/cvs/libvirt/src/opennebula/one_client.h,v retrieving revision 1.1 diff -u -p -r1.1 one_client.h --- src/opennebula/one_client.h 24 Jun 2009 17:32:56 -0000 1.1 +++ src/opennebula/one_client.h 30 Jun 2009 11:05:12 -0000 @@ -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); -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list