This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] enlarge allowable size of diagnostic strings


Wouldn't it be better to put the if outside the loop? At the moment
its evaluated for every character. This will catch a string that is not
terminated within 256 characters. If you put it outside the loop there
is a small danger that a string does not have a termination before the
end of memory. In that case you will get an exception when you fall of
the edge of the world rather than a "Not a string" message. But you
get a speedup in the normal case.

    Andrew

On Thu, Jan 17, 2002 at 12:57:38PM +0100, jeroen dobbelaere wrote:
> Following patch makes the reasonable length of what is 'known' to
> be a string more reasonable ;)
> 
> diff -cNr ecos/packages/infra/current/src/diag.cxx ecos_unified_flash/packages/infra/current/src/diag.cxx
> *** ecos/packages/infra/current/src/diag.cxx	Fri Dec  7 15:15:05 2001
> --- ecos_unified_flash/packages/infra/current/src/diag.cxx	Thu Jan 17 12:36:48 2002
> ***************
> *** 227,233 ****
> 
>            /* Check for a reasonable length string. */
> 
> !         if( s-str > 256 ) result = false;
> 
>            /* We only really support CR, NL, and backspace at present. If
>             * we want to use tabs or other special chars, this test will
> --- 227,233 ----
> 
>            /* Check for a reasonable length string. */
> 
> !         if( s-str > 2048 ) result = false;
> 
>            /* We only really support CR, NL, and backspace at present. If
>             * we want to use tabs or other special chars, this test will
> diff -cNr ecos/packages/infra/current/ChangeLog ecos_unified_flash/packages/infra/current/ChangeLog
> *** ecos/packages/infra/current/ChangeLog	Fri Dec  7 15:15:05 2001
> --- ecos_unified_flash/packages/infra/current/ChangeLog	Thu Jan 17 12:49:07 2002
> ***************
> *** 1,3 ****
> --- 1,7 ----
> + 2002-01-17  Jeroen Dobbelaere  <jeroen.dobbelaere@acunia.com>
> +
> + 	* src/diag.cxx (diag_check_string): enlarge valid string length to 2048
> +
>    2001-12-06  Jesper Skov  <jskov@redhat.com>
> 
>    	* src/diag.cxx: Added functions to do memory dump in 16 and 32 bit
> 
> 
> --
> Jeroen Dobbelaere
> Embedded Software Engineer
> 
> ACUNIA Embedded Solutions
> http://www.acunia.com
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]