From 0cf023e592c6e94ab7b13c8ae49e64cc7e3d7b1a Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Tue, 14 Mar 2006 00:33:22 +0000
Subject: [PATCH] Clean-up some typecasting problems uint32_t/int.

---
 src/common/dist_tasks.c                           |  9 +++++----
 src/common/dist_tasks.h                           |  2 +-
 src/common/switch.c                               | 12 ++++++------
 src/common/switch.h                               | 10 +++++-----
 src/plugins/switch/elan/qsw.c                     |  4 ++--
 src/plugins/switch/elan/qsw.h                     |  2 +-
 src/plugins/switch/elan/switch_elan.c             |  2 +-
 src/plugins/switch/federation/switch_federation.c |  3 ++-
 src/plugins/switch/none/switch_none.c             |  2 +-
 src/slurmctld/step_mgr.c                          |  2 +-
 10 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/common/dist_tasks.c b/src/common/dist_tasks.c
index 85e23fc4c4e..f32768d3e3e 100644
--- a/src/common/dist_tasks.c
+++ b/src/common/dist_tasks.c
@@ -67,12 +67,13 @@ static int _task_layout_cyclic(slurm_step_layout_t *step_layout);
  * RET a pointer to an integer array listing task counts per node
  * NOTE: allocates memory that should be xfreed by caller
  */
-int *distribute_tasks(const char *mlist, uint16_t num_cpu_groups,
+uint32_t *distribute_tasks(const char *mlist, uint16_t num_cpu_groups,
 			uint32_t *cpus_per_node, uint32_t *cpu_count_reps,
 			const char *tlist, uint32_t num_tasks) 
 {
 	hostlist_t master_hl = NULL, task_hl = NULL;
-	int i, index, count, hostid, nnodes, ncpus, *cpus, *ntask = NULL;
+	int i, index, count, hostid, nnodes, ncpus;
+	uint32_t *cpus, *ntask = NULL;
 	char *this_node_name;
 	
 	if (!tlist || num_tasks == 0)
@@ -85,7 +86,7 @@ int *distribute_tasks(const char *mlist, uint16_t num_cpu_groups,
 		fatal("hostlist_create error for %s: %m", tlist);
 
 	nnodes = hostlist_count(task_hl);
-	ntask = (int *) xmalloc(sizeof(int *) * nnodes);
+	ntask = (uint32_t *) xmalloc(sizeof(uint32_t *) * nnodes);
 	if (!ntask) {
 		hostlist_destroy(master_hl);
 		hostlist_destroy(task_hl);
@@ -137,7 +138,7 @@ int *distribute_tasks(const char *mlist, uint16_t num_cpu_groups,
 	 * by the cpu constraints.
 	 */
 	cpus = ntask;
-	ntask = (int *) xmalloc(sizeof(int *) * nnodes);
+	ntask = (uint32_t *) xmalloc(sizeof(int *) * nnodes);
 	if (!ntask) {
 		slurm_seterrno(ENOMEM);
 		xfree(cpus);
diff --git a/src/common/dist_tasks.h b/src/common/dist_tasks.h
index ebc996a1342..3d2d6c6933b 100644
--- a/src/common/dist_tasks.h
+++ b/src/common/dist_tasks.h
@@ -78,7 +78,7 @@ typedef struct slurm_step_layout {
  * RET a pointer to an integer array listing task counts per node
  * NOTE: allocates memory that should be xfreed by caller
  */
-int * distribute_tasks(const char *mlist,
+uint32_t * distribute_tasks(const char *mlist,
 		       uint16_t num_cpu_groups,
 		       uint32_t *cpus_per_node,
 		       uint32_t *cpu_count_reps,
diff --git a/src/common/switch.c b/src/common/switch.c
index 59d1b7f60ca..b81ebc5a8b8 100644
--- a/src/common/switch.c
+++ b/src/common/switch.c
@@ -1,7 +1,7 @@
 /*****************************************************************************\
- * src/common/switch.c - Generic switch (interconnect) for slurm
+ *  src/common/switch.c - Generic switch (interconnect) for slurm
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
  *  UCRL-CODE-217948.
@@ -51,7 +51,7 @@ typedef struct slurm_switch_ops {
 	int          (*alloc_jobinfo)     ( switch_jobinfo_t *jobinfo );
 	int          (*build_jobinfo)     ( switch_jobinfo_t jobinfo,
 						char *nodelist,
-						int *tasks_per_node, 
+						uint32_t *tasks_per_node, 
 						int cyclic_alloc, 
 						char *network);
 	switch_jobinfo_t (*copy_jobinfo)  ( switch_jobinfo_t jobinfo );
@@ -331,14 +331,14 @@ extern int  switch_alloc_jobinfo(switch_jobinfo_t *jobinfo)
 }
 
 extern int  switch_build_jobinfo(switch_jobinfo_t jobinfo, 
-		char *nodelist, int *tasks_per_node, int cyclic_alloc,
-		char *network)
+		char *nodelist, uint32_t *tasks_per_node, 
+		int cyclic_alloc, char *network)
 {
 	if ( switch_init() < 0 )
 		return SLURM_ERROR;
 
 	return (*(g_context->ops.build_jobinfo))( jobinfo, nodelist, 
-			(int *)tasks_per_node, cyclic_alloc, network );
+			tasks_per_node, cyclic_alloc, network );
 }
 
 extern switch_jobinfo_t switch_copy_jobinfo(switch_jobinfo_t jobinfo)
diff --git a/src/common/switch.h b/src/common/switch.h
index 8a0bcecc2c0..1bbeeb897b6 100644
--- a/src/common/switch.h
+++ b/src/common/switch.h
@@ -1,7 +1,7 @@
 /*****************************************************************************\
- * src/common/switch.h - Generic switch (interconnect) info for slurm
+ *  src/common/switch.h - Generic switch (interconnect) info for slurm
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Morris Jette <jette1@llnl.gov>.
  *  UCRL-CODE-217948.
@@ -109,14 +109,14 @@ extern int  switch_alloc_jobinfo (switch_jobinfo_t *jobinfo);
 /* fill a job's switch credential
  * OUT jobinfo  - storage for a switch job credential
  * IN  nodelist - list of nodes to be used by the job
- * IN  nprocs   - count of tasks in the job
+ * IN  tasks_per_node   - count of tasks per node in the job
  * IN  cyclic_alloc - task distribution pattern, 1=cyclic, 0=block
  * IN  network  - plugin-specific network info (e.g. protocol)
  * NOTE: storage must be freed using g_switch_free_jobinfo
  */
 extern int  switch_build_jobinfo (switch_jobinfo_t jobinfo, 
-		char *nodelist, int *tasks_per_node, int cyclic_alloc, 
-		char *network);
+		char *nodelist, uint32_t *tasks_per_node, 
+		int cyclic_alloc, char *network);
 
 /* copy a switch job credential
  * IN jobinfo - the switch job credential to be copied
diff --git a/src/plugins/switch/elan/qsw.c b/src/plugins/switch/elan/qsw.c
index 316949a29ee..37082948861 100644
--- a/src/plugins/switch/elan/qsw.c
+++ b/src/plugins/switch/elan/qsw.c
@@ -755,7 +755,7 @@ _free_hwcontext(uint32_t prog_num)
  */
 static int
 _init_elan_capability(ELAN_CAPABILITY *cap, uint32_t prognum, int ntasks, 
-		int nnodes, bitstr_t *nodeset, int *tasks_per_node,
+		int nnodes, bitstr_t *nodeset, uint32_t *tasks_per_node,
 		int cyclic_alloc, int max_tasks_per_node)
 {
 	int i, node_index;
@@ -855,7 +855,7 @@ _init_elan_capability(ELAN_CAPABILITY *cap, uint32_t prognum, int ntasks,
  */
 int
 qsw_setup_jobinfo(qsw_jobinfo_t j, int ntasks, bitstr_t *nodeset, 
-		int *tasks_per_node, int cyclic_alloc)
+		uint32_t *tasks_per_node, int cyclic_alloc)
 {
 	int i, max_tasks_per_node = 0;
 	int nnodes = bit_set_count(nodeset);
diff --git a/src/plugins/switch/elan/qsw.h b/src/plugins/switch/elan/qsw.h
index 484cea7aeab..b2891041143 100644
--- a/src/plugins/switch/elan/qsw.h
+++ b/src/plugins/switch/elan/qsw.h
@@ -97,7 +97,7 @@ int		qsw_pack_jobinfo(qsw_jobinfo_t j, Buf buffer);
 int		qsw_unpack_jobinfo(qsw_jobinfo_t j, Buf buffer);
 
 int 		qsw_setup_jobinfo(qsw_jobinfo_t j, int ntasks, 
-			bitstr_t *nodeset, int *tasks_per_node,
+			bitstr_t *nodeset, uint32_t *tasks_per_node,
 			int cyclic_alloc);
 void		qsw_teardown_jobinfo(qsw_jobinfo_t j);
 
diff --git a/src/plugins/switch/elan/switch_elan.c b/src/plugins/switch/elan/switch_elan.c
index 3d163073bd6..14600622e96 100644
--- a/src/plugins/switch/elan/switch_elan.c
+++ b/src/plugins/switch/elan/switch_elan.c
@@ -313,7 +313,7 @@ int switch_p_alloc_jobinfo(switch_jobinfo_t *jp)
 }
 
 int switch_p_build_jobinfo ( switch_jobinfo_t switch_job, char *nodelist,
-		int *tasks_per_node, int cyclic_alloc, char *network)
+		uint32_t *tasks_per_node, int cyclic_alloc, char *network)
 {
 	int node_set_size = QSW_MAX_TASKS; /* overkill but safe */
 	hostlist_t host_list;
diff --git a/src/plugins/switch/federation/switch_federation.c b/src/plugins/switch/federation/switch_federation.c
index 79def839c2a..cf815807228 100644
--- a/src/plugins/switch/federation/switch_federation.c
+++ b/src/plugins/switch/federation/switch_federation.c
@@ -368,7 +368,8 @@ static char *adapter_name_check(char *network)
 }
 
 int switch_p_build_jobinfo(switch_jobinfo_t switch_job, char *nodelist, 
-			   int *tasks_per_node, int cyclic_alloc, char *network) 
+			uint32_t *tasks_per_node, int cyclic_alloc, 
+			char *network) 
 {
 	hostlist_t list = NULL;
 	bool sn_all;
diff --git a/src/plugins/switch/none/switch_none.c b/src/plugins/switch/none/switch_none.c
index 0eb301ad20d..a58f4e22e44 100644
--- a/src/plugins/switch/none/switch_none.c
+++ b/src/plugins/switch/none/switch_none.c
@@ -107,7 +107,7 @@ int switch_p_alloc_jobinfo ( switch_jobinfo_t *switch_job )
 }
 
 int switch_p_build_jobinfo ( switch_jobinfo_t switch_job, char *nodelist, 
-		int *tasks_per_node, int cyclic_alloc, char *network)
+		uint32_t *tasks_per_node, int cyclic_alloc, char *network)
 {
 	return SLURM_SUCCESS;
 }
diff --git a/src/slurmctld/step_mgr.c b/src/slurmctld/step_mgr.c
index a33fbb77de9..e6f5fb80a1a 100644
--- a/src/slurmctld/step_mgr.c
+++ b/src/slurmctld/step_mgr.c
@@ -653,7 +653,7 @@ step_create ( job_step_create_request_msg_t *step_specs,
 
 	/* a batch script does not need switch info */
 	if (!batch_step) {
-		int *tasks_per_node;
+		uint32_t *tasks_per_node;
 		tasks_per_node = distribute_tasks(job_ptr->nodes,
 						  job_ptr->num_cpu_groups,
 						  job_ptr->cpus_per_node,
-- 
GitLab