[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: The --password and clumsy users issue

From: Ben Reser <ben_at_reser.org>
Date: Thu, 03 Jul 2014 19:34:27 -0700

On 7/3/14 4:50 PM, Gabriela Gibson wrote:> it compiles and runs and in gdb the
vars do change, but the compiler isn't happy:
> subversion/svn/svn.c: In function 'main':
> subversion/svn/svn.c:3048:23: warning: assignment discards 'const' qualifier
> from pointer target type [enable\
> d by default]
> argv[i-1] = "#####\0";
> ^
> subversion/svn/svn.c:3052:23: warning: assignment discards 'const' qualifier
> from pointer target type [enable\
> d by default]
> argv[i-1] = "#####\0";

The main function has the const qualifier on argv. You either need to remove
that or cast it away.

> At breakpoint B, gdb gives me:
> (gdb) p argv
> $1 = (char **) 0x7fffffffe468
> (gdb) p argv[1]
> $2 = 0x7fffffffe81e "svn"
> (gdb) p argv[2]
> $3 = 0x7fffffffe822 "help"
> (gdb) p argv[3]
> $4 = 0x4438b3 "#####"
> (gdb)
> So it def. does change it.

Right you're doing what I said didn't work. argv is an array of strings (as
opposed to a string which is just an array of characters), so you have two
levels of arrays. You're trying to change out the whole string that a given
element of the argv array points at. You need to change out the individual
characters in the string without changing the pointer in the argv array. See
the example I posted it does work.

On 7/3/14 5:14 PM, Gabriela Gibson wrote:
> I also looked at the C90 standard because I thought maybe they defined argv as
> immutable (since it should not complain about being const with this type of
> main declaration I think) and this is what is says:
> "The parameters argc and argv and the strings pointed to by the argv array shall
> be modifiable by the program, and retain their last-stored values between
> program
> startup and program termination."
> This seems a bit ambiguous --- so it's changeable, but between start up and
> termination they retain their value?

Yes it's perfectly legal to change them. If you change them they will continue
to retain whatever value you change them to as long as the program stays running.

> So, that is maybe why the kernel's info isn't changing but the args can be
> modified?

Like I said before, I suspect that the argv array itself is local to the
program and not shared with the kernel. So changing the pointers in it to
other strings isn't visible to the kernel. The strings that are there when the
program starts however, appear to be shared with the kernel and so if you
update them the kernel sees the change.

I don't think the C standards specify this sort of behavior but something has
to be shared between the kernel and the process in order to allow this
Received on 2014-07-04 04:34:58 CEST

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.