Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

From: Jeff Squyres (jsquyres_at_[hidden])
Date: 2007-04-17 09:21:16


Don't you also need to cast the return of strtol() to an int?

On Apr 17, 2007, at 9:12 AM, Sharon Melamed wrote:

> Hi,
>
> I added an MCA parameter and I want the user to apply an Hex value
> to this parameter (0x…).
>
> In order to do so I needed to change the ‘atoi’ call in the
> mca_base_param.c file to ‘strtol’ call.
>
>
>
> My question is: Can this code run on all platforms?
>
>
>
> Index: opal/mca/base/mca_base_param.c
>
> ===================================================================
>
> --- opal/mca/base/mca_base_param.c (revision 14391)
>
> +++ opal/mca/base/mca_base_param.c (working copy)
>
> @@ -1673,7 +1673,7 @@
>
> if (NULL != param->mbp_env_var_name &&
>
> NULL != (env = getenv(param->mbp_env_var_name))) {
>
> if (MCA_BASE_PARAM_TYPE_INT == param->mbp_type) {
>
> - storage->intval = atoi(env);
>
> + storage->intval = strtol(env,(char**)NULL,0);
>
> } else if (MCA_BASE_PARAM_TYPE_STRING == param->mbp_type) {
>
> storage->stringval = strdup(env);
>
> }
>
> @@ -1714,7 +1714,7 @@
>
> if (0 == strcmp(fv->mbpfv_param, param->mbp_full_name)) {
>
> if (MCA_BASE_PARAM_TYPE_INT == param->mbp_type) {
>
> if (NULL != fv->mbpfv_value) {
>
> - param->mbp_file_value.intval = atoi(fv-
> >mbpfv_value);
>
> + param->mbp_file_value.intval = strtol(fv-
> >mbpfv_value,(char**)NULL,0);
>
> } else {
>
> param->mbp_file_value.intval = 0;
>
> }
>
>
>
>
>
> Thanks.
>
>
>
> Sharon.
>
> _______________________________________________
> devel mailing list
> devel_at_[hidden]
> http://www.open-mpi.org/mailman/listinfo.cgi/devel

-- 
Jeff Squyres
Cisco Systems