[gPXE-devel] Minor Scripting Improvements

Michael Brown mbrown at fensystems.co.uk
Fri Mar 5 11:30:24 EST 2010


On Friday 05 Mar 2010 16:17:37 Shao Miller wrote:
> I value further feedback from anyone interested.

Looking at the patch itself:

> + start_script:
> +    offset = 0;
>      while ( offset < image->len ) {
> 
>          /* Find length of next line, excluding any terminating '\n' */
> @@ -73,12 +77,24 @@ static int script_exec ( struct image *image ) {
>              }
>          }
> 
> +        if ( shell_exit_flag )
> +            /* "exit" command should exit this script */
> +            goto done;
>          /* Move to next line */
>          offset += ( len + 1 );
>      }
> 
>      rc = 0;
>   done:
> +    /* Reset exit flag */
> +    shell_exit_flag = 0;
> +
> +    /* Check if we should loop.  We might as well use ENOTSUP,
> +     * since we don't use it for anything else in this file
> +     */
> +    if ( rc == -ENOTSUP )
> +        goto start_script;
> +

Could this be rearranged to avoid goto?  We generally use goto only for 
structured error clean-up.

Also, using -ENOTSUP as a magic value meaning "loop" seems kind of icky.  
There's a similarity between "exit" and "loopif" here; both commands need to 
set temporary state that affects the "move to next line of script" logic.  
Maybe have "loopif" set a flag as well; still fairly icky but at least it's 
icky in the same way that "exit" currently is.

Michael


More information about the gPXE-devel mailing list