Re: [PATCH 1/1] mesh: Fixed warning-to-error from GCC 8.1.1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Brian,

> Fixed compiler flagged unsafe usage of strncpy
> ---
> mesh/storage.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/mesh/storage.c b/mesh/storage.c
> index 85fa81dda..1be403297 100644
> --- a/mesh/storage.c
> +++ b/mesh/storage.c
> @@ -298,13 +298,14 @@ bool storage_parse_config(struct mesh_net *net, const char *config_name)
> 	result = parse_config(net, config_name, false);
> 
> 	if (!result) {
> -		char *bak = (char *) l_malloc(strlen(config_name) + 5);
> +		size_t len = strlen(config_name) + 5;
> +		char *bak = (char *) l_malloc(len);

The (char *) cast is utterly pointless since l_malloc return void *.

> 
> 		if (!bak)
> 			goto done;

So why are we still doing? l_malloc will abort if no memory can be allocated. We need to stop dealing with memory allocation error handling. If you need that large memory then malloc should be used. If you use l_malloc then expect the daemon might be killed. Which is fine systemd can restart it.

Regards

Marcel




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux