Re: [DNG] Pointer error in the backend of Netman

2015-12-14 Thread Rainer Weikusat
Steve Litt writes: > On Thu, 10 Dec 2015 12:28:15 + > Rainer Weikusat wrote: > >> *p = 5 >> >> is undefined behaviour. > > Not in the good old days. Anyone remember DOS' infamous B800 address? 'undefined behaviour' is a term from the C standard and 'using the value of an object with automat

Re: [DNG] Pointer error in the backend of Netman

2015-12-13 Thread aitor_czr
Hi Ron, On 12/13/2015 10:48 PM, Renaud (Ron) OLGIATI wrote: *p = 5 > > > >is undefined behaviour. > >Not in the good old days. Anyone remember DOS' infamous B800 address? > >But of course in 2015, my response is offtopic. Abend 0C7 (or 0CB) anyone ? Cheers, Ron. -- Physics is like sex:

Re: [DNG] Pointer error in the backend of Netman

2015-12-13 Thread Ron
On Sun, 13 Dec 2015 13:25:02 -0500 Steve Litt wrote: > > *p = 5 > > > > is undefined behaviour. > > Not in the good old days. Anyone remember DOS' infamous B800 address? > > But of course in 2015, my response is offtopic. Abend 0C7 (or 0CB) anyone ? Cheers, Ron. -- Ph

Re: [DNG] Pointer error in the backend of Netman

2015-12-13 Thread Steve Litt
On Thu, 10 Dec 2015 12:28:15 + Rainer Weikusat wrote: > *p = 5 > > is undefined behaviour. Not in the good old days. Anyone remember DOS' infamous B800 address? But of course in 2015, my response is offtopic. SteveT Steve Litt November 2015 featured book: Troubleshooting Techniques

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread Hendrik Boom
On Fri, Dec 11, 2015 at 01:04:18PM +0100, Irrwahn wrote: > > [pedantic mode=full] There is no C/C++ language. Those > are two distinct languages, looking uncannily similar > in places. Unfortunately. [pedantic/] Nonetheless, it is possible, and even practical, to write a program in the interse

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread Hendrik Boom
On Fri, Dec 11, 2015 at 11:23:24AM +, KatolaZ wrote: > > C is one of the few remaining languages which is consistent about > allowing only one of the many possible argument passing > mechanisms. And the mechanism chosen by C is pass-by-value. Fullstop. Historical note: it may have picked up t

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread Irrwahn
[top-posting fixed] On Fri, 11 Dec 2015 12:25:00 +0100, Aitor Czr wrote: > On 12/11/2015 10:04 AM, Irrwahn wrote: >> Ceterum censeo: There is no pass by reference in C, >> has never been, and will presumably never be. Heck, >> the C standard doesn't mention the concept at all, >> not even in a no

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread aitor_czr
Of course :-) On 12/11/2015 12:23 PM, KatolaZ wrote: This is not being pedantic, but calling things with their name, and avoiding confusion. ___ Dng mailing list Dng@lists.dyne.org https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread aitor_czr
Maybe... Here you are the same program written in both languages: CASE 1 (C Language): # include void func(int*); int main(void) { int i=1; func(&i); printf( "%d", i); return 0; } void func(int *x) { *x = 2; } CASE 2 (C++ Language): #include void func(int &); int main() {

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread KatolaZ
On Fri, Dec 11, 2015 at 09:01:19AM +0100, aitor_czr wrote: > Hi Katolaz, > > Here you are an example of two arguments (x,y) passed by reference: [cut] > > void func(int *x, int *y) > { > int k = *x; > *x = *y; > *y = k; > } > > This is the output: > > i = 1 j = 2 > i = 2 j = 1 > Dear A

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread Irrwahn
[top-posting fixed] On Fri, 11 Dec 2015 10:59:05 +0100, Aitor Czr wrote: > On 12/11/2015 10:04 AM, Irrwahn wrote: >> Ugh, this explains a lot! Books by Herbert Schildt >> are, sit venia verbo, the most useless utter crap >> you can get. The only thing this book documents is >> the total incomp

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread Irrwahn
On Fri, 11 Dec 2015 09:49:25 +, Arnt Gulbrandsen wrote: > aitor_...@gnuinos.org writes: >> They wrote the following book: >> >> "The C programming language" > > I read both editions in my time and... isn't there anything better yet? The > book is short and gets to the point, but the code samp

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread aitor_czr
Maybe it doesn't deserve a Pulitzer :) Aitor. On 12/11/2015 10:04 AM, Irrwahn wrote: Ugh, this explains a lot! Books by Herbert Schildt are, sit venia verbo, the most useless utter crap you can get. The only thing this book documents is the total incompetence of its author. Have a good laugh

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread Arnt Gulbrandsen
aitor_...@gnuinos.org writes: They wrote the following book: "The C programming language" I read both editions in my time and... isn't there anything better yet? The book is short and gets to the point, but the code samples are terribly happypathish, with weak and unstated pre- and postcondi

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread Irrwahn
[top posting fixed] On Fri, 11 Dec 2015 10:31:08 +0100, Aitor Czr wrote: > On 12/11/2015 10:04 AM, Irrwahn wrote: >> If you want an overall introductory book to C, get >> K&R2, written by someone who understood C, if only >> because he invented the language. :P If you want an >> authoritative

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread aitor_czr
They wrote the following book: "The C programming language" Aitor. On 12/11/2015 10:31 AM, aitor_czr wrote: Hi Irrwahn, Are you referring to Brian Kernighan and Dennis Ritchie? Aitor. On 12/11/2015 10:04 AM, Irrwahn wrote: If you want an overall introductory book to C, get K&R2, wri

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread aitor_czr
Hi Irrwahn, Are you referring to Brian Kernighan and Dennis Ritchie? Aitor. On 12/11/2015 10:04 AM, Irrwahn wrote: If you want an overall introductory book to C, get K&R2, written by someone who understood C, if only because he invented the language. :P If you want an authoritative refere

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread Irrwahn
On Fri, 11 Dec 2015 09:01:19 +0100, Aitor Czr wrote: [...] > Passing by value and passing by reference in ANSI C99 are documented in the > following book: > > C - The Complete Reference (by Herbert Schildt) Ugh, this explains a lot! Books by Herbert Schildt are, sit venia verbo, the most useles

Re: [DNG] Pointer error in the backend of Netman

2015-12-11 Thread aitor_czr
Hi Katolaz, Here you are an example of two arguments (x,y) passed by reference: # include int main(void) { int i=1; int j=2; printf( "i = %d j = %d \n", i,j); func(&i, &j); printf( "i = %d j = %d \n", i,j); return 0; } void func(int *x, int *y) { int k = *x; *x = *y; *y = k;

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread KatolaZ
On Thu, Dec 10, 2015 at 05:59:04PM +, Rainer Weikusat wrote: > Edward Bartolo writes: > > [...] > > > Realloc uses two parameters: the first is a pointer whose allocation > > is to be modified/reallocated. The second is the NEW number of bytes > > required. In the function line 240 is: > > a

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread Rainer Weikusat
Edward Bartolo writes: [...] > Realloc uses two parameters: the first is a pointer whose allocation > is to be modified/reallocated. The second is the NEW number of bytes > required. In the function line 240 is: > active_wifi_list = realloc(active_wifi_list, (((z - 1)/2) + > list_delta)*sizeof(v

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread Edward Bartolo
Hi Aitor et al, This is the working code. At least it worked with an initial allocation of 1 structure instead of 10. I am using it with an initial allocation of 10 structures. On this machine the code works and it should also work in your case: The code is attached. Conside lines 236 - 240. Li

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread KatolaZ
On Thu, Dec 10, 2015 at 04:11:27PM +, KatolaZ wrote: [cut] > > with > > $ gcc -std=c99 reference.c > > this is what I obtain: > > reference.c:3:16: error: expected ‘;’, ‘,’ or ‘)’ before ‘&’ token > void myfun(int &a){ > ^ > reference.c: In function ‘main’: > reference.

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread KatolaZ
On Thu, Dec 10, 2015 at 05:00:58PM +0100, aitor_czr wrote: > No, Katolaz, passing by value and passing by reference exist in C, > at least in C99. > Could you please give a pointer to the place where this feature is documented in the ANSI C99 standard? Because it seems that the GCC crew has overl

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
Hi Katolaz, Can you say me what returns in your system the following command: $ echo $PEDANTIC_MODE Is it set to FALSE? Thanks in advance, Aitor. On 12/10/2015 02:20 PM, KatolaZ wrote: OK, but that's*really* pedantic;) HND KatolaZ ___ Dng

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
No, Katolaz, passing by value and passing by reference exist in C, at least in C99. Aitor. On 12/10/2015 02:08 PM, KatolaZ wrote: Aitor, sorry for being pedantic on this, but "passing-by-reference" exists only in C++, not in C. ___ Dng mailing l

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread KatolaZ
On Thu, Dec 10, 2015 at 01:13:00PM +, Rainer Weikusat wrote: [cut] > > Hence, there is no way in C in which "p" and "&p" can be "the same > > thing", especially if you have to decide to use either "p" or "&p" as > > a first parameter of realloc... > > There is, but not in a way which would m

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread Rainer Weikusat
KatolaZ writes: > On Thu, Dec 10, 2015 at 01:11:21PM +0100, aitor_czr wrote: >> Hi Katolaz, >> >> In this case active_wifis is an argument passed by reference. So: >> >> active_wifis --> is the address >> *active_wifis --> is the value >> > > Aitor, sorry for being pedantic on this, but "passi

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread KatolaZ
On Thu, Dec 10, 2015 at 01:11:21PM +0100, aitor_czr wrote: > Hi Katolaz, > > In this case active_wifis is an argument passed by reference. So: > > active_wifis --> is the address > *active_wifis --> is the value > Aitor, sorry for being pedantic on this, but "passing-by-reference" exists only

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread KatolaZ
On Thu, Dec 10, 2015 at 01:40:38PM +0100, aitor_czr wrote: > Hi Katolaz, > > (Sorry if i send the same post several times, but many of them are > being undelivered today) > > Try the folling code: > > int x = 5; > int *p,*q; > > p=&x; // This is -> *p=5 > q=p; > > printf(" The values are:

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
Hi Katolaz, (Sorry if i send the same post several times, but many of them are being undelivered today) Try the folling code: int x = 5; int *p,*q; p=&x; // This is -> *p=5 q=p; printf(" The values are:%d %d ", *p,*q); printf(" The addresses are: %p %p ", p, q); So: 1) active_w

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
Hi Katolaz, Try the folling code: int x = 5; int *p,*q; p=&x; // This is -> *p=5 q=p; printf(" The values are:%d %d ", *p,*q); printf(" The addresses are: %p %p ", p, q); So: 1) active_wifis is the address 2) *active_wifis is the value Aitor. On 12/10/2015 12:56 PM, KatolaZ wro

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread Rainer Weikusat
aitor_czr writes: > I rectify: > > p = &x; // This is -> *p=5 Considering >> int x = 5; >> int *p, *q; >> >> p = &x; // This is -> p=5 it's not. It's p = &x. Afterwards, *p will return whatever value x happens to have. Prior to the assigned, p was (assuming auto variables) a pointer wi

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
I rectify: p = &x; // This is -> *p=5 On 12/10/2015 01:11 PM, aitor_czr wrote: Hi Katolaz, In this case active_wifis is an argument passed by reference. So: active_wifis --> is the address *active_wifis --> is the value Try doing: int x = 5; int *p, *q; p = &x; // This is -> p=5 q

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
Hi Katolaz, In this case active_wifis is an argument passed by reference. So: active_wifis --> is the address *active_wifis --> is the value Try doing: int x = 5; int *p, *q; p = &x; // This is -> p=5 q = p; printf(" The values are: %d %d ", *p, *q); printf(" The addresses are:

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread KatolaZ
On Thu, Dec 10, 2015 at 11:05:01AM +0100, aitor_czr wrote: > Hi again, > > ... "active_wifis" and "&active_wifis" are the same ... > > So, forget the comment. Sorry for the silly, uninformed, and preposterous comment, which you would probably be better off ignoring altogether, but I can't se

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
Hi again, ... "active_wifis" and "&active_wifis" are the same ... So, forget the comment. The origin of the pointer error, as Edward said, is in the list of my neighbouring active wifi points. Now, i am in another house: # ./backend 6 ESSID:"Orange-F879" ESSID:"WLAN_74B3" ESSID:"Orange-

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
Changing from: realloc(active_wifis to: realloc(&active_wifis . the pointer error disappears: # ./backend 10 /sbin/ifup: interface wlan0 already configured :) Aitor. On 12/10/2015 09:58 AM, aitor_czr wrote: Sorry: printf("\nactive_wifis = %i\n\n", *active_wifis); On 12/10/2015 09:

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
Sorry: printf("\nactive_wifis = %i\n\n", *active_wifis); On 12/10/2015 09:30 AM, aitor_czr wrote: Hi Edward, The value of the integer parameter 'active_wifis', passed by reference to 'getRadiatingWifiList' is lost. I added the following line 232: [] *active_wifis = -1; char* tmp_buffer

Re: [DNG] Pointer error in the backend of Netman

2015-12-10 Thread aitor_czr
Hi Edward, The value of the integer parameter 'active_wifis', passed by reference to 'getRadiatingWifiList' is lost. I added the following line 232: [] *active_wifis = -1; char* tmp_buffer = scan_buffer; printf("\nactive_wifis = %i\n\n", active_wifis); /* ADDED LINE / while((scan

Re: [DNG] Pointer error in the backend of Netman

2015-12-07 Thread Edward Bartolo
Hi Rainer, Edited Makefile as you instructed me. Now, using "make -C ." in netman/ directory creates two executables: netman (GUI frontend) and backend (CLI backend). Please ignore the "Sender" parameter not used warnings. It is normal not to use Sender although there are instances where it is us

Re: [DNG] Pointer error in the backend of Netman

2015-12-07 Thread Rainer Weikusat
Edward Bartolo writes: > Hi Rainer, > > This is Makefile from netman: > > --- > all: backend netman > > backend: > make -C backend_src > cp backend_src/bin/backend . > > netman: netman.lpr > lazbuild -B netman.lpr | awk '/./{p

Re: [DNG] Pointer error in the backend of Netman

2015-12-07 Thread Edward Bartolo
Hi Rainer, This is Makefile from netman: --- all: backend netman backend: make -C backend_src cp backend_src/bin/backend . netman: netman.lpr lazbuild -B netman.lpr | awk '/./{print $$0}' clean: make -C backend_src

Re: [DNG] Pointer error in the backend of Netman

2015-12-07 Thread Rainer Weikusat
Edward Bartolo writes: > QUOTE: > > "NB: This also fixes the silly autoWirelessScanPlus_RN omission (by > including all object files). But this is positively the last time I've > either > > - created backend_src/obj by hand > - created backend_src/bin by hand > - added auto

Re: [DNG] Pointer error in the backend of Netman

2015-12-07 Thread Edward Bartolo
Hi, To compile manually the backend, cd to: netman/backend_src/src gcc -I../include -lm -Wall automated_scanner.c core_functions.c essid_encoder.c file_functions.c backend.c -o backend Edward On 07/12/2015, Edward Bartolo wrote: > Hi Reiner, > > QUOTE: > > "NB: This also fixes the silly autoWi

Re: [DNG] Pointer error in the backend of Netman

2015-12-07 Thread Edward Bartolo
Hi Reiner, QUOTE: "NB: This also fixes the silly autoWirelessScanPlus_RN omission (by including all object files). But this is positively the last time I've either - created backend_src/obj by hand - created backend_src/bin by hand - added automated_scanner.o by hand

Re: [DNG] Pointer error in the backend of Netman

2015-12-07 Thread Rainer Weikusat
aitor_czr writes: > Now i get the following error trying to compile the backend: > > " ... automated_scanner.c:291: undefined reference to `pow' ... " > > The 'pow' function is part of the 'math' library. Therefore, the > invokation of the compiler should be as follows: > > $ gcc -g -lm [...] > >

Re: [DNG] Pointer error in the backend of Netman

2015-12-07 Thread aitor_czr
Hi Edward, Now i get the following error trying to compile the backend: " ... automated_scanner.c:291: undefined reference to `pow' ... " The 'pow' function is part of the 'math' library. Therefore, the invokation of the compiler should be as follows: $ gcc -g -lm [...] in order to link wit

Re: [DNG] Pointer error in the backend of Netman

2015-12-06 Thread Edward Bartolo
Hi Aitor, This is my latest edit of the code so that memory allocations are done when needed instead of the iteration just before more memory is required. The edited code: if (z == 1) active_wifi_list = calloc(10, sizeof(void*)); else if ((z

Re: [DNG] Pointer error in the backend of Netman

2015-12-06 Thread aitor_czr
Hi Edward, I will try it later, thanks :) Aitor. On 12/06/2015 01:10 PM, Edward Bartolo wrote: Hi Aitor, I edited the code as follows: if (z == 1) active_wifi_list = calloc(10, sizeof(void*)); else if (z % 20 == 0)

Re: [DNG] Pointer error in the backend of Netman

2015-12-06 Thread Edward Bartolo
Hi Aitor, I edited the code as follows: if (z == 1) active_wifi_list = calloc(10, sizeof(void*)); else if (z % 20 == 0) active_wifi_list = realloc(active_wifis, ((z/2) + 10)*sizeof(void*)); Please, if you can run th

Re: [DNG] Pointer error in the backend of Netman

2015-12-06 Thread Edward Bartolo
Hi Aitor, Nevermind, I confirmed it is the same line we are talking about. I will investigate the source and reply back. Edward On 06/12/2015, Edward Bartolo wrote: > Hi Aitor, > > Could you attach the source file so that I would be able to make sure > we are talking about the same version? > >

Re: [DNG] Pointer error in the backend of Netman

2015-12-06 Thread Edward Bartolo
Hi Aitor, Could you attach the source file so that I would be able to make sure we are talking about the same version? Edward On 06/12/2015, Edward Bartolo wrote: > Hi Aitor, > > Is your list of neighbouring active wifi points larger than 9 or 10? > If that is the case, we may have hit an untes

Re: [DNG] Pointer error in the backend of Netman

2015-12-06 Thread Edward Bartolo
Hi Aitor, Is your list of neighbouring active wifi points larger than 9 or 10? If that is the case, we may have hit an untested code path. I will review the code and post back. Edward On 06/12/2015, aitor_czr wrote: > Hi all, > > In the case of an automatically attempt to connect with netman, i

[DNG] Pointer error in the backend of Netman

2015-12-06 Thread aitor_czr
Hi all, In the case of an automatically attempt to connect with netman, i get the following error: $ ./backend 10 *** Error in `./backend': realloc(): invalid pointer: 0x7ffc3deb55f4 *** Aborted I believe there is an uncontrolled pointer somewhere... IMHO (:-) ) the line 238 of ''automat