Re: [DNG] int essid_alloc is causing valgrind to report a series, of errors

2015-10-15 Thread Rainer Weikusat
aitor_czr writes: > Hi Edward, > > You are pointing *result to a pointer 'tmp' declared locally inside > the function 'essid_alloc', whose value will be lost outside it... > > Is it right? No, it's not. At the point of the assignment, the value of tmp is some value returned by calloc. And that's

[DNG] int essid_alloc is causing valgrind to report a series, of errors

2015-10-15 Thread aitor_czr
Hi Edward, You are pointing *result to a pointer 'tmp' declared locally inside the function 'essid_alloc', whose value will be lost outside it... Is it right? Aitor. On 14/10/15 21:29, Edward Bartolo wrote: int essid_alloc( size_t length, char ** result ) { char * t

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-15 Thread Edward Bartolo
Suppose this is a string in which we are interested: The value of Pi is 3.142 approximately. The index of the space preceding Pi is: 18 - 1 = 17 The index of the space after Pi is: 24 - 1 = 23 The length of the decimal number is: 5 characters, which is also: 23 - 17 - 1 = 5 If we were to copy t

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-15 Thread Rainer Weikusat
Peter Olson writes: >> On October 14, 2015 at 3:20 PM Edward Bartolo wrote: >> >> >> This is another part of the backend code where valgrind is saying: >> >> ==5501== 5 errors in context 1 of 3: >> ==5501== Use of uninitialised value of size 8 >> ==5501==at 0x5172AFC: strtod_l_internal

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-15 Thread Rainer Weikusat
Peter Olson writes: >> On October 14, 2015 at 3:20 PM Edward Bartolo wrote: >> >> >> This is another part of the backend code where valgrind is saying: >> >> ==5501== 5 errors in context 1 of 3: >> ==5501== Use of uninitialised value of size 8 >> ==5501==at 0x5172AFC: strtod_l_internal

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-14 Thread Peter Olson
> On October 14, 2015 at 3:20 PM Edward Bartolo wrote: > > > This is another part of the backend code where valgrind is saying: > > ==5501== 5 errors in context 1 of 3: > ==5501== Use of uninitialised value of size 8 > ==5501==at 0x5172AFC: strtod_l_internal (strtod_l.c:889) > ==5501==

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-14 Thread Jaromil
On Wed, 14 Oct 2015, Mat wrote: > Is there a reason why you need to write such a wrapper around calloc()? good question. I also have been tempted to do that in the past. > It adds very little since calloc already sets errno. Plus it's a rather > unnatural construct for an allocator to return the

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-14 Thread Rainer Weikusat
Edward Bartolo writes: > This is another part of the backend code where valgrind is saying: > > ==5501== 5 errors in context 1 of 3: > ==5501== Use of uninitialised value of size 8 > ==5501==at 0x5172AFC: strtod_l_internal (strtod_l.c:889) > ==5501==by 0x403856: getRadiatingWifiList (a

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-14 Thread Edward Bartolo
This is another part of the backend code where valgrind is saying: ==5501== 5 errors in context 1 of 3: ==5501== Use of uninitialised value of size 8 ==5501==at 0x5172AFC: strtod_l_internal (strtod_l.c:889) ==5501==by 0x403856: getRadiatingWifiList (automated_scanner.c:265) ==5501==

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-14 Thread Rainer Weikusat
Edward Bartolo writes: > The problem according to my logic seems to be result is used in a > branch control expression before it is initialised. However, I am > emailing this to have other opinions. > > > int essid_alloc( > size_t length, > char ** result > ) { > char * tmp; > >

Re: [DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-14 Thread Mat
Is there a reason why you need to write such a wrapper around calloc()? It adds very little since calloc already sets errno. Plus it's a rather unnatural construct for an allocator to return the allocated buffer this way. if ((err = essid_alloc(len, &buf)) != 0) handle_error(err); if (!(b

[DNG] int essid_alloc is causing valgrind to report a series of errors

2015-10-14 Thread Edward Bartolo
Dear All, The problem according to my logic seems to be result is used in a branch control expression before it is initialised. However, I am emailing this to have other opinions. int essid_alloc( size_t length, char ** result ) { char * tmp; if(length==0 || !res