The HyperNews Linux KHG Discussion Pages

Question: Re:return values

Forum: The Linux Kernel Hackers' Guide
Re: Question Problem creating a new system call
Re: Question system call returns "Bad Address". Why?
Date: Wed, 15 Oct 1997 18:04:38 GMT
From: C.H.Gopinath <[email protected]>

 I created the following call it is working fine, but i don't know about that bad address.

sys call function looks like this.

int sys_print_data(char *s1,char *s2,int flag,int size1,int size2)
{
/* size1 and size2 are strlen of s1 and s2 respectively */
      if (flag) {
		 sys_write(1,s1,size1);
		 return 1;
      else {
		sys_write(1,s2,size2);
		return 2;

      }
}

This is working fine. But i have another problem. I wrote a function  int string_len(char *s), which will return the
length of the string as follows.

int string_length(char *s)
{
	int len=0;

	while(*(s+len))
		len++;
	return len;
}

i am calling this in the sys_print_data instead of passing size1 and size2. Exactly at this call it is saying
segmentation fault and dumping all the registers.

i also used the standard strlen call(linux/string.h).
It is also doing the same.

Can any body please clarify this.

Thanx in advance,
	Gopinath