× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hi Rory,

Like you, I don't know 100% for sure. What I say here is an educated guess, based mainly on experience:

If I call a program passing too many parameters, what will happen?

Caller allocates memory for an integer to contain the parameter count, and a variable length array of pointers, one for each parameter. (allocated memory would be %size(pointer) * parameter count.)

Called program will behave differently, depending on the language.

assuming the called program won't throw a fit, but will OS/400 take note?

I don't think so, no. But, it may depend on how you called the program. Did you use the CALL command? a *CMD interface? The SQL Call command? But, AFIAK, the OS doesn't really care. Other than having a different value for the parm count, and allocating a little more memory for the pointer array.


know some IBM programs throw an error, but I assume (again!) that this is
program-specific code which checks for too many parameters.

In the *called* program, yes. But not in the caller or OS.

For example, an OPM CL program *must* be passed the exact number of parameters that it's expecting. Otherwise, it'll throw an error.

OPM RPG will throw an error if you pass too many parameters, but NOT if you pass too few.

ILE RPG won't throw any error, but the user-written code is able to check the parameter count via the %PARMS BIF or PSDS. So while RPG itself won't care, the user written code might care, or might malfunction.

ILE CL works like ILE RPG, it doesn't care if you pass the right number of parameters. (Except, I don't know how to get the parameter count in ILE CL -- but there might be a way, maybe it's just me.)

ILE C works like ILE RPG as well, except that unlike ILE RPG, the extra parameters would be accessible to the program, since the program doesn't necessarily need to know the number of parameters at compile-time.


If I define a prototype for the called program with the extra parameter
being CONST, could there be any memory overwriting problems? I don't think
so, but I'd like to know.

No, there shouldn't be, since the caller knows the right number of parameters and is the one that allocates the memory.

But, again, some languages will check the parm count and complain if it doesn't match, so your idea might not work, depending on whether you need to call those languages.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.