diff options
| author | Leandro Pereira <leandro@hardinfo.org> | 2020-05-03 10:51:38 -0700 | 
|---|---|---|
| committer | Leandro Pereira <leandro@hardinfo.org> | 2020-05-03 14:08:12 -0700 | 
| commit | 707b2484dadded505f766be4593d127ea16a2892 (patch) | |
| tree | 58ad0a8ce03d5f631fe9006670fd86878be1ef4d | |
| parent | cedaec6c9e6611bec090247df09f6138c19d2fc5 (diff) | |
hi_exported_methods() should return a const pointer
| -rw-r--r-- | hardinfo/util.c | 6 | ||||
| -rw-r--r-- | modules/benchmark.c | 7 | ||||
| -rw-r--r-- | modules/computer.c | 6 | ||||
| -rw-r--r-- | modules/devices.c | 32 | 
4 files changed, 27 insertions, 24 deletions
| diff --git a/hardinfo/util.c b/hardinfo/util.c index d8c77e78..4a27299a 100644 --- a/hardinfo/util.c +++ b/hardinfo/util.c @@ -583,7 +583,7 @@ static GHashTable *__module_methods = NULL;  static void module_register_methods(ShellModule * module)  { -    ShellModuleMethod *(*get_methods) (void); +    const ShellModuleMethod *(*get_methods)(void);      gchar *method_name;      if (__module_methods == NULL) { @@ -591,8 +591,8 @@ static void module_register_methods(ShellModule * module)      }      if (g_module_symbol -	(module->dll, "hi_exported_methods", (gpointer) & get_methods)) { -	ShellModuleMethod *methods; +	(module->dll, "hi_exported_methods", (gpointer)&get_methods)) { +	const ShellModuleMethod *methods;  	for (methods = get_methods(); methods->name; methods++) {  	    ShellModuleMethod method = *methods; diff --git a/modules/benchmark.c b/modules/benchmark.c index ab4f8145..6bf41d45 100644 --- a/modules/benchmark.c +++ b/modules/benchmark.c @@ -751,9 +751,12 @@ static gchar *run_benchmark(gchar *name)      return NULL;  } -ShellModuleMethod *hi_exported_methods(void) +const ShellModuleMethod *hi_exported_methods(void)  { -    static ShellModuleMethod m[] = {{"runBenchmark", run_benchmark}, {NULL}}; +    static const ShellModuleMethod m[] = { +        {"runBenchmark", run_benchmark}, +        {NULL}, +    };      return m;  } diff --git a/modules/computer.c b/modules/computer.c index 925822a9..0346e3e2 100644 --- a/modules/computer.c +++ b/modules/computer.c @@ -953,9 +953,9 @@ const gchar *get_memory_desc(void) // [1] const (as to say "don't free")      return (gchar*)idle_free(avail); // [1] idle_free()  } -ShellModuleMethod *hi_exported_methods(void) +const ShellModuleMethod *hi_exported_methods(void)  { -    static ShellModuleMethod m[] = { +    static const ShellModuleMethod m[] = {          {"getOSKernel", get_os_kernel},          {"getOS", get_os},          {"getDisplaySummary", get_display_summary}, @@ -964,7 +964,7 @@ ShellModuleMethod *hi_exported_methods(void)          {"getKernelModuleDescription", get_kernel_module_description},          {"getMemoryTotal", get_memory_total},          {"getMemoryDesc", get_memory_desc}, -        {NULL} +        {NULL},      };      return m; diff --git a/modules/devices.c b/modules/devices.c index fef8b559..7eae11b9 100644 --- a/modules/devices.c +++ b/modules/devices.c @@ -543,22 +543,22 @@ gchar *get_motherboard(void)      return g_strdup(_("Unknown"));  } -ShellModuleMethod *hi_exported_methods(void) -{ -    static ShellModuleMethod m[] = { -	{"getProcessorCount", get_processor_count}, -	{"getProcessorName", get_processor_name}, -	{"getProcessorDesc", get_processor_desc}, -	{"getProcessorNameAndDesc", get_processor_name_and_desc}, -	{"getProcessorFrequency", get_processor_max_frequency}, -	{"getProcessorFrequencyDesc", get_processor_frequency_desc}, -	{"getStorageDevices", get_storage_devices}, -	{"getStorageDevicesSimple", get_storage_devices_simple}, -	{"getPrinters", get_printers}, -	{"getInputDevices", get_input_devices}, -	{"getMotherboard", get_motherboard}, -	{"getGPUList", get_gpu_summary}, -	{NULL} +const ShellModuleMethod *hi_exported_methods(void) +{ +    static const ShellModuleMethod m[] = { +        {"getProcessorCount", get_processor_count}, +        {"getProcessorName", get_processor_name}, +        {"getProcessorDesc", get_processor_desc}, +        {"getProcessorNameAndDesc", get_processor_name_and_desc}, +        {"getProcessorFrequency", get_processor_max_frequency}, +        {"getProcessorFrequencyDesc", get_processor_frequency_desc}, +        {"getStorageDevices", get_storage_devices}, +        {"getStorageDevicesSimple", get_storage_devices_simple}, +        {"getPrinters", get_printers}, +        {"getInputDevices", get_input_devices}, +        {"getMotherboard", get_motherboard}, +        {"getGPUList", get_gpu_summary}, +        {NULL},      };      return m; | 
