From c6350abd4782c84fe96f9b55b6e20c7e6a437433 Mon Sep 17 00:00:00 2001
From: jimmycao <jimmy.cao@emc.com>
Date: Mon, 18 Feb 2013 16:47:22 +0800
Subject: [PATCH] modify some annotation, and cleanup

---
 src/plugins/slurmctld/dynalloc/allocate.c   |  38 +--
 src/plugins/slurmctld/dynalloc/allocate.h   |  23 +-
 src/plugins/slurmctld/dynalloc/allocator.c  |  50 +--
 src/plugins/slurmctld/dynalloc/allocator.h  |  12 +-
 src/plugins/slurmctld/dynalloc/argv.h       | 358 ++++++++++----------
 src/plugins/slurmctld/dynalloc/deallocate.c |  12 +-
 src/plugins/slurmctld/dynalloc/deallocate.h |  12 +-
 src/plugins/slurmctld/dynalloc/info.c       |  58 +---
 src/plugins/slurmctld/dynalloc/info.h       |  31 +-
 src/plugins/slurmctld/dynalloc/msg.c        |   2 +-
 10 files changed, 282 insertions(+), 314 deletions(-)

diff --git a/src/plugins/slurmctld/dynalloc/allocate.c b/src/plugins/slurmctld/dynalloc/allocate.c
index bae17cef9c7..8c53ae4da22 100644
--- a/src/plugins/slurmctld/dynalloc/allocate.c
+++ b/src/plugins/slurmctld/dynalloc/allocate.c
@@ -87,11 +87,11 @@ static int _setup_job_desc_msg(uint32_t np, uint32_t request_node_num,
  *	node_range_list, allocation should include all nodes
  *	in the given list that are currently available. If
  *	that isn't enough to meet the request_node_num,
- * 	then take  any other nodes that are available to
+ * 	then take any other nodes that are available to
  * 	fill out the requested number.
  *
  *	IN:
- *		request_node_num: requested node num
+ *		request_node_num: requested node number
  *		node_range_list: specified node range to select from
  *	OUT Parameter:
  *		final_req_node_list
@@ -161,12 +161,12 @@ static int _get_nodelist_optional(uint16_t request_node_num,
  *	from node_range_list
  *
  *	IN:
- *		request_node_num: requested node num
+ *		request_node_num: requested node number
  *		node_range_list: specified node range to select from
  *	OUT Parameter:
  *		final_req_node_list
  *	RET OUT
- *		-1 if requested node number is larger than available or timeout
+ *		-1 if requested node number is larger than available
  *		0  successful, final_req_node_list is returned
  */
 static int _get_nodelist_mandatory(uint16_t request_node_num,
@@ -199,9 +199,8 @@ static int _get_nodelist_mandatory(uint16_t request_node_num,
 }
 
 /*
- * Note: the return should be xfree(ptr)
+ * Note: the return should be xfree(str)
  */
-
 static char* _uint16_array_to_str_xmalloc(int array_len,
 								const uint16_t *array)
 {
@@ -243,7 +242,7 @@ static char* _uint16_array_to_str_xmalloc(int array_len,
  *	OUT Parameter:
  *		tasks_per_node
  *	RET OUT
- *		-1 if timeout
+ *		-1 if failed
  *		0  successful, tasks_per_node is returned
  */
 static int _get_tasks_per_node(
@@ -283,6 +282,7 @@ static int _get_tasks_per_node(
 	tmp = _uint16_array_to_str_xmalloc(step_layout->node_cnt, step_layout->tasks);
 
 	slurm_step_layout_destroy(step_layout);
+
 	if (NULL != tmp)
 		strcpy(tasks_per_node, tmp);
 
@@ -295,14 +295,14 @@ static int _get_tasks_per_node(
  *
  *	IN:
  *		np: number of process to run
- *		request_node_num: requested node amount
+ *		request_node_num: the amount of requested node
  *		node_range_list: requested node pool
  *		flag: optional or mandatory
  *		timeout:
  *	OUT Parameter:
  *		job_desc_msg
  *	RET OUT
- *		-1 if timeout
+ *		-1 if failed
  *		0  successful, job_desc_msg is returned
  */
 static int _setup_job_desc_msg(uint32_t np, uint32_t request_node_num,
@@ -395,20 +395,19 @@ static int _setup_job_desc_msg(uint32_t np, uint32_t request_node_num,
  *  nodes that are available to fill out the requested number.
  *
  *	IN:
- *		request_node_num: requested node num
+ *		np: number of process to run
+ *		request_node_num: requested node number
  *		node_range_list: specified node range to select from
  *		flag: optional or mandatory
  *		timeout: timeout
- *		hint: to indicate this function is first called or iteration
  *	OUT Parameter:
  *		jobid: slurm jobid
  *		reponse_node_list:
  *		tasks_per_node: like 4(x2) 3,2
- *	RET OUT
+ *	RET OUT:
  *		-1 if requested node number is larger than available or timeout
  *		0  successful
  */
-
 int allocate_node_rpc(uint32_t np, uint32_t request_node_num,
 		      char *node_range_list, const char *flag,
 		      time_t timeout, uint32_t *slurm_jobid,
@@ -465,15 +464,16 @@ int allocate_node_rpc(uint32_t np, uint32_t request_node_num,
  *  nodes that are available to fill out the requested number.
  *
  *	IN:
- *		request_node_num: requested node num
+ *		np: number of process to run
+ *		request_node_num: requested node number
  *		node_range_list: specified node range to select from
  *		flag: optional or mandatory
  *		timeout: timeout
- *		hint: to indicate this function is first called or iteration
  *	OUT Parameter:
- *		jobid: slurm jobid
+ *		slurm_jobid: slurm jobid
  *		reponse_node_list:
- *	RET OUT
+ *		tasks_per_node: like 4(x2) 3,2
+ *	RET OUT:
  *		-1 if requested node number is larger than available or timeout
  *		0  successful, final_req_node_list is returned
  */
@@ -606,8 +606,8 @@ int allocate_node(uint32_t np, uint32_t request_node_num,
  *		job_id: slurm jobid
  *		uid: user id
  *	OUT Parameter:
- *	RET OUT
- *		-1 failure
+ *	RET OUT:
+ *		-1 failed
  *		0  successful
  */
 int cancel_job(uint32_t job_id, uid_t uid)
diff --git a/src/plugins/slurmctld/dynalloc/allocate.h b/src/plugins/slurmctld/dynalloc/allocate.h
index becd71a50a8..9afb87f26c5 100644
--- a/src/plugins/slurmctld/dynalloc/allocate.h
+++ b/src/plugins/slurmctld/dynalloc/allocate.h
@@ -63,17 +63,18 @@
  *  nodes that are available to fill out the requested number.
  *
  *	IN:
- *		request_node_num: requested node num
+ *		np: number of process to run
+ *		request_node_num: requested node number
  *		node_range_list: specified node range to select from
  *		flag: optional or mandatory
  *		timeout: timeout
- *		hint: to indicate this function is first called or iteration
  *	OUT Parameter:
  *		jobid: slurm jobid
  *		reponse_node_list:
- *	RET OUT
+ *		tasks_per_node: like 4(x2) 3,2
+ *	RET OUT:
  *		-1 if requested node number is larger than available or timeout
- *		0  successful, final_req_node_list is returned
+ *		0  successful
  */
 extern int allocate_node_rpc(uint32_t np, uint32_t request_node_num,
 			     char *node_range_list, const char *flag,
@@ -92,16 +93,16 @@ extern int allocate_node_rpc(uint32_t np, uint32_t request_node_num,
  *  nodes that are available to fill out the requested number.
  *
  *	IN:
- *		np: number of process
- *		request_node_num: requested node num
+ *		np: number of process to run
+ *		request_node_num: requested node number
  *		node_range_list: specified node range to select from
  *		flag: optional or mandatory
  *		timeout: timeout
- *		hint: to indicate this function is first called or iteration
  *	OUT Parameter:
- *		jobid: slurm jobid
+ *		slurm_jobid: slurm jobid
  *		reponse_node_list:
- *	RET OUT
+ *		tasks_per_node: like 4(x2) 3,2
+ *	RET OUT:
  *		-1 if requested node number is larger than available or timeout
  *		0  successful, final_req_node_list is returned
  */
@@ -117,8 +118,8 @@ extern int allocate_node(uint32_t np, uint32_t request_node_num,
  *		job_id: slurm jobid
  *		uid: user id
  *	OUT Parameter:
- *	RET OUT
- *		-1 failure
+ *	RET OUT:
+ *		-1 failed
  *		0  successful
  */
 extern int cancel_job(uint32_t job_id, uid_t uid);
diff --git a/src/plugins/slurmctld/dynalloc/allocator.c b/src/plugins/slurmctld/dynalloc/allocator.c
index 8f09fe7739e..f9ff571c05a 100644
--- a/src/plugins/slurmctld/dynalloc/allocator.c
+++ b/src/plugins/slurmctld/dynalloc/allocator.c
@@ -54,21 +54,24 @@ static void _parse_app_params(const char *cmd, char *appid,
 					uint32_t *np, uint32_t *request_node_num,
 					char *node_range_list, char *flag);
 
-static int _allocate_app_op(const char *msg_app,
+static void _allocate_app_op(const char *msg_app,
 							size_t app_timeout,
 							char *app_resp_msg);
 
 /*
  * Parse the job part of msg(cmd) to obtain job parameters
  *
+ *	e.g., if a allocate request is like "allocate jobid=100
+ *	return=all timeout=10:app=0 np=5 N=2 node_list=vm2,vm3
+ *	flag=mandatory:app=1 N=2", then the job part of msg is
+ *	"jobid=100 return=all timeout=10".
+ *
  * IN:
  * 	cmd: job part of msg
  * OUT Parameter:
- * 	orte_jobid
- * 	return_flag
- * 	job_timeout
- * RET OUT:
- * 	void
+ * 	orte_jobid:
+ * 	return_flag:
+ * 	job_timeout: timeout of resource allocation for the whole job
  */
 static void _parse_job_params(const char *cmd, char *orte_jobid,
 					char *return_flag,	size_t *job_timeout)
@@ -103,16 +106,19 @@ static void _parse_job_params(const char *cmd, char *orte_jobid,
 /*
  * Parse the app part of msg(cmd) to obtain app parameters
  *
+ *	e.g., if a allocate request is like "allocate jobid=100
+ *	return=all timeout=10:app=0 np=5 N=2 node_list=vm2,vm3
+ *	flag=mandatory:app=1 N=2", then the app part of msg is
+ *	"app=0 np=5 N=2 node_list=vm2,vm3 flag=mandatory:app=1 N=2".
+ *
  * IN:
  * 	cmd: app part of msg
  * OUT Parameter:
- * 	appid
+ * 	appid:
  * 	np: number of process
- * 	request_node_num
- * 	node_range_list
- * 	flag
- * RET OUT:
- * 	void
+ * 	request_node_num:
+ * 	node_range_list:
+ * 	flag: mandatory or optional
  */
 static void _parse_app_params(const char *cmd, char *appid,
 					uint32_t *np, uint32_t *request_node_num,
@@ -154,17 +160,15 @@ static void _parse_app_params(const char *cmd, char *appid,
 }
 
 /*
- * allocate resource for app
+ * allocate resource for an app
  *
  * IN:
  * 	msg_app: cmd of allocation requirement
  * 	app_timeout:
  * OUT Parameter:
  * 	app_resp_msg: allocation result
- * RET OUT:
- *
  */
-static int _allocate_app_op(const char *msg_app,
+static void _allocate_app_op(const char *msg_app,
 							size_t app_timeout,
 							char *app_resp_msg)
 {
@@ -197,16 +201,16 @@ static int _allocate_app_op(const char *msg_app,
 
 /*
  * allocate resources for a job.
- * The job can consist of several apps.
+ *
+ * The job will consist of at least one app, e.g., "allocate
+ * jobid=100 return=all timeout=10:app=0 np=5 N=2
+ * node_list=vm2,vm3 flag=mandatory:app=1 N=2".
  *
  * IN:
  * 	new_fd: send allocation result to socket_fd
- * 	msg: resource requirement
- * OUT Parameter:
- * RET OUT:
- *
+ * 	msg: resource requirement cmd
  */
-extern int allocate_job_op(slurm_fd_t new_fd, const char *msg)
+extern void allocate_job_op(slurm_fd_t new_fd, const char *msg)
 {
 	char orte_jobid[16] = "";
 	char return_flag[16] = "";
@@ -262,6 +266,4 @@ extern int allocate_job_op(slurm_fd_t new_fd, const char *msg)
 		info("BBB: send to client: %s", send_buf);
 		send_reply(new_fd, send_buf);
 	}
-
-	return SLURM_SUCCESS;
 }
diff --git a/src/plugins/slurmctld/dynalloc/allocator.h b/src/plugins/slurmctld/dynalloc/allocator.h
index 5616cb48243..ddf0758a83a 100644
--- a/src/plugins/slurmctld/dynalloc/allocator.h
+++ b/src/plugins/slurmctld/dynalloc/allocator.h
@@ -56,15 +56,15 @@
 
 /*
  * allocate resources for a job.
- * The job can consist of several apps.
+ *
+ * The job will consist of at least one app, e.g., "allocate
+ * jobid=100 return=all timeout=10:app=0 np=5 N=2
+ * node_list=vm2,vm3 flag=mandatory:app=1 N=2".
  *
  * IN:
  * 	new_fd: send allocation result to socket_fd
- * 	msg: resource requirement
- * OUT Parameter:
- * RET OUT:
- *
+ * 	msg: resource requirement cmd
  */
-extern int allocate_job_op(slurm_fd_t new_fd, const char *msg);
+extern void allocate_job_op(slurm_fd_t new_fd, const char *msg);
 
 #endif /* DYNALLOC_ALLOCATOR_H_ */
diff --git a/src/plugins/slurmctld/dynalloc/argv.h b/src/plugins/slurmctld/dynalloc/argv.h
index f021d632713..0edef74490d 100644
--- a/src/plugins/slurmctld/dynalloc/argv.h
+++ b/src/plugins/slurmctld/dynalloc/argv.h
@@ -55,52 +55,52 @@
 #include <sys/types.h>
 #endif
 
-  /**
-   * Append a string (by value) to an new or existing NULL-terminated
-   * argv array.
-   *
-   * @param argc Pointer to the length of the argv array.  Must not be
-   * NULL.
-   * @param argv Pointer to an argv array.
-   * @param str Pointer to the string to append.
-   *
-   * @retval DYNALLOC_SUCCESS On success
-   * @retval DYNALLOC_ERROR On failure
-   *
-   * This function adds a string to an argv array of strings by value;
-   * it is permissable to pass a string on the stack as the str
-   * argument to this function.
-   *
-   * To add the first entry to an argv array, call this function with
-   * (*argv == NULL).  This function will allocate an array of length
-   * 2; the first entry will point to a copy of the string passed in
-   * arg, the second entry will be set to NULL.
-   *
-   * If (*argv != NULL), it will be realloc'ed to be 1 (char*) larger,
-   * and the next-to-last entry will point to a copy of the string
-   * passed in arg.  The last entry will be set to NULL.
-   *
-   * Just to reinforce what was stated above: the string is copied by
-   * value into the argv array; there is no need to keep the original
-   * string (i.e., the arg parameter) after invoking this function.
-   */
+/**
+ * Append a string (by value) to an new or existing NULL-terminated
+ * argv array.
+ *
+ * @param argc Pointer to the length of the argv array.  Must not be
+ * NULL.
+ * @param argv Pointer to an argv array.
+ * @param str Pointer to the string to append.
+ *
+ * @retval DYNALLOC_SUCCESS On success
+ * @retval DYNALLOC_ERROR On failure
+ *
+ * This function adds a string to an argv array of strings by value;
+ * it is permissable to pass a string on the stack as the str
+ * argument to this function.
+ *
+ * To add the first entry to an argv array, call this function with
+ * (*argv == NULL).  This function will allocate an array of length
+ * 2; the first entry will point to a copy of the string passed in
+ * arg, the second entry will be set to NULL.
+ *
+ * If (*argv != NULL), it will be realloc'ed to be 1 (char*) larger,
+ * and the next-to-last entry will point to a copy of the string
+ * passed in arg.  The last entry will be set to NULL.
+ *
+ * Just to reinforce what was stated above: the string is copied by
+ * value into the argv array; there is no need to keep the original
+ * string (i.e., the arg parameter) after invoking this function.
+ */
 extern int argv_append(int *argc, char ***argv, const char *arg);
 
-  /**
-   * Append to an argv-style array, but ignore the size of the array.
-   *
-   * @param argv Pointer to an argv array.
-   * @param str Pointer to the string to append.
-   *
-   * @retval DYNALLOC_SUCCESS On success
-   * @retval DYNALLOC_ERROR On failure
-   *
-   * This function is identical to the argv_append() function
-   * except that it does not take a pointer to an argc (integer
-   * representing the size of the array).  This is handy for
-   * argv-style arrays that do not have integers that are actively
-   * maintaing their sizes.
-   */
+/**
+ * Append to an argv-style array, but ignore the size of the array.
+ *
+ * @param argv Pointer to an argv array.
+ * @param str Pointer to the string to append.
+ *
+ * @retval DYNALLOC_SUCCESS On success
+ * @retval DYNALLOC_ERROR On failure
+ *
+ * This function is identical to the argv_append() function
+ * except that it does not take a pointer to an argc (integer
+ * representing the size of the array).  This is handy for
+ * argv-style arrays that do not have integers that are actively
+ * maintaing their sizes.
+ */
 extern  int argv_append_nosize(char ***argv, const char *arg);
 
 /**
@@ -133,161 +133,161 @@ extern  int argv_append_unique_nosize(char ***argv, const char *arg,
 				      bool overwrite);
 
 /**
-   * Free a NULL-terminated argv array.
-   *
-   * @param argv Argv array to free.
-   *
-   * This function frees an argv array and all of the strings that it
-   * contains.  Since the argv parameter is passed by value, it is not
-   * set to NULL in the caller's scope upon return.
-   *
-   * It is safe to invoke this function with a NULL pointer.  It is
-   * not safe to invoke this function with a non-NULL-terminated argv
-   * array.
-   */
+ * Free a NULL-terminated argv array.
+ *
+ * @param argv Argv array to free.
+ *
+ * This function frees an argv array and all of the strings that it
+ * contains.  Since the argv parameter is passed by value, it is not
+ * set to NULL in the caller's scope upon return.
+ *
+ * It is safe to invoke this function with a NULL pointer.  It is
+ * not safe to invoke this function with a non-NULL-terminated argv
+ * array.
+ */
 extern  void argv_free(char **argv);
 
-  /**
-   * Split a string into a NULL-terminated argv array. Do not include empty
-   * strings in result array.
-   *
-   * @param src_string Input string.
-   * @param delimiter Delimiter character.
-   *
-   * @retval argv pointer to new argv array on success
-   * @retval NULL on error
-   *
-   * All strings are insertted into the argv array by value; the
-   * newly-allocated array makes no references to the src_string
-   * argument (i.e., it can be freed after calling this function
-   * without invalidating the output argv).
-   */
+/**
+ * Split a string into a NULL-terminated argv array. Do not include empty
+ * strings in result array.
+ *
+ * @param src_string Input string.
+ * @param delimiter Delimiter character.
+ *
+ * @retval argv pointer to new argv array on success
+ * @retval NULL on error
+ *
+ * All strings are insertted into the argv array by value; the
+ * newly-allocated array makes no references to the src_string
+ * argument (i.e., it can be freed after calling this function
+ * without invalidating the output argv).
+ */
 extern  char **argv_split(const char *src_string, int delimiter);
 
-  /**
-   * Split a string into a NULL-terminated argv array. Include empty
-   * strings in result array.
-   *
-   * @param src_string Input string.
-   * @param delimiter Delimiter character.
-   *
-   * @retval argv pointer to new argv array on success
-   * @retval NULL on error
-   *
-   * All strings are insertted into the argv array by value; the
-   * newly-allocated array makes no references to the src_string
-   * argument (i.e., it can be freed after calling this function
-   * without invalidating the output argv).
-   */
+/**
+ * Split a string into a NULL-terminated argv array. Include empty
+ * strings in result array.
+ *
+ * @param src_string Input string.
+ * @param delimiter Delimiter character.
+ *
+ * @retval argv pointer to new argv array on success
+ * @retval NULL on error
+ *
+ * All strings are insertted into the argv array by value; the
+ * newly-allocated array makes no references to the src_string
+ * argument (i.e., it can be freed after calling this function
+ * without invalidating the output argv).
+ */
 extern  char **argv_split_with_empty(const char *src_string, int delimiter) ;
 
-  /**
-   * Return the length of a NULL-terminated argv array.
-   *
-   * @param argv The input argv array.
-   *
-   * @retval 0 If NULL is passed as argv.
-   * @retval count Number of entries in the argv array.
-   *
-   * The argv array must be NULL-terminated.
-   */
+/**
+ * Return the length of a NULL-terminated argv array.
+ *
+ * @param argv The input argv array.
+ *
+ * @retval 0 If NULL is passed as argv.
+ * @retval count Number of entries in the argv array.
+ *
+ * The argv array must be NULL-terminated.
+ */
 extern  int argv_count(char **argv);
 
-  /**
-   * Join all the elements of an argv array into a single
-   * newly-allocated string.
-   *
-   * @param argv The input argv array.
-   * @param delimiter Delimiter character placed between each argv string.
-   *
-   * @retval new_string Output string on success.
-   * @retval NULL On failure.
-   *
-   * Similar to the Perl join function, this function takes an input
-   * argv and joins them into into a single string separated by the
-   * delimiter character.
-   *
-   * It is the callers responsibility to free the returned string.
-   */
+/**
+ * Join all the elements of an argv array into a single
+ * newly-allocated string.
+ *
+ * @param argv The input argv array.
+ * @param delimiter Delimiter character placed between each argv string.
+ *
+ * @retval new_string Output string on success.
+ * @retval NULL On failure.
+ *
+ * Similar to the Perl join function, this function takes an input
+ * argv and joins them into into a single string separated by the
+ * delimiter character.
+ *
+ * It is the callers responsibility to free the returned string.
+ */
 extern  char *argv_join(char **argv, int delimiter) ;
 
 extern char *argv_join_range(char **argv, size_t start, size_t end,
 			     int delimiter);
 
-  /**
-   * Return the number of bytes consumed by an argv array.
-   *
-   * @param argv The input argv array.
-   *
-   * Count the number of bytes consumed by a NULL-terminated argv
-   * array.  This includes the number of bytes used by each of the
-   * strings as well as the pointers used in the argv array.
-   */
+/**
+ * Return the number of bytes consumed by an argv array.
+ *
+ * @param argv The input argv array.
+ *
+ * Count the number of bytes consumed by a NULL-terminated argv
+ * array.  This includes the number of bytes used by each of the
+ * strings as well as the pointers used in the argv array.
+ */
 extern  size_t argv_len(char **argv);
 
-  /**
-   * Copy a NULL-terminated argv array.
-   *
-   * @param argv The input argv array.
-   *
-   * @retval argv Copied argv array on success.
-   * @retval NULL On failure.
-   *
-   * Copy an argv array, including copying all off its strings.
-   * Specifically, the output argv will be an array of the same length
-   * as the input argv, and strcmp(argv_in[i], argv_out[i]) will be 0.
-   */
+/**
+ * Copy a NULL-terminated argv array.
+ *
+ * @param argv The input argv array.
+ *
+ * @retval argv Copied argv array on success.
+ * @retval NULL On failure.
+ *
+ * Copy an argv array, including copying all off its strings.
+ * Specifically, the output argv will be an array of the same length
+ * as the input argv, and strcmp(argv_in[i], argv_out[i]) will be 0.
+ */
 extern char **argv_copy(char **argv);
 
-    /**
-     * Delete one or more tokens from the middle of an argv.
-     *
-     * @param argv The argv to delete from
-     * @param start The index of the first token to delete
-     * @param num_to_delete How many tokens to delete
-     *
-     * @retval DYNALLOC_SUCCESS Always
-     *
-     * Delete some tokens from within an existing argv.  The start
-     * parameter specifies the first token to delete, and will delete
-     * (num_to_delete-1) tokens following it.  argv will be realloc()ed
-     * to *argc - num_deleted size.
-     *
-     * If start is beyond the end of the argv array, this function is
-     * a no-op.
-     *
-     * If num_to_delete runs beyond the end of the argv array, this
-     * function will delete all tokens starting with start to the end
-     * of the array.
-     *
-     * All deleted items in the argv array will have their contents
-     * free()ed (it is assumed that the argv "owns" the memory that
-     * the pointer points to).
-     */
+/**
+ * Delete one or more tokens from the middle of an argv.
+ *
+ * @param argv The argv to delete from
+ * @param start The index of the first token to delete
+ * @param num_to_delete How many tokens to delete
+ *
+ * @retval DYNALLOC_SUCCESS Always
+ *
+ * Delete some tokens from within an existing argv.  The start
+ * parameter specifies the first token to delete, and will delete
+ * (num_to_delete-1) tokens following it.  argv will be realloc()ed
+ * to *argc - num_deleted size.
+ *
+ * If start is beyond the end of the argv array, this function is
+ * a no-op.
+ *
+ * If num_to_delete runs beyond the end of the argv array, this
+ * function will delete all tokens starting with start to the end
+ * of the array.
+ *
+ * All deleted items in the argv array will have their contents
+ * free()ed (it is assumed that the argv "owns" the memory that
+ * the pointer points to).
+ */
 extern  int argv_delete(int *argc, char ***argv,
                                     int start, int num_to_delete);
 
-    /**
-     * Insert one argv array into the middle of another
-     *
-     * @param target The argv to insert tokens into
-     * @param start Index where the first token will be placed in target
-     * @param source The argv to copy tokens from
-     *
-     * @retval DYNALLOC_SUCCESS upon success
-     * @retval DYNALLOC_BAD_PARAM if any parameters are non-sensical
-     *
-     * This function takes one arg and inserts it in the middle of
-     * another.  The first token in source will be insertted at index
-     * start in the target argv; all other tokens will follow it.
-     * Similar to argv_append(), the target may be realloc()'ed
-     * to accomodate the new storage requirements.
-     *
-     * The source array is left unaffected -- its contents are copied
-     * by value over to the target array (i.e., the strings that
-     * source points to are strdup'ed into the new locations in
-     * target).
-     */
+/**
+ * Insert one argv array into the middle of another
+ *
+ * @param target The argv to insert tokens into
+ * @param start Index where the first token will be placed in target
+ * @param source The argv to copy tokens from
+ *
+ * @retval DYNALLOC_SUCCESS upon success
+ * @retval DYNALLOC_BAD_PARAM if any parameters are non-sensical
+ *
+ * This function takes one arg and inserts it in the middle of
+ * another.  The first token in source will be insertted at index
+ * start in the target argv; all other tokens will follow it.
+ * Similar to argv_append(), the target may be realloc()'ed
+ * to accomodate the new storage requirements.
+ *
+ * The source array is left unaffected -- its contents are copied
+ * by value over to the target array (i.e., the strings that
+ * source points to are strdup'ed into the new locations in
+ * target).
+ */
 extern  int argv_insert(char ***target, int start, char **source);
 
 /**
diff --git a/src/plugins/slurmctld/dynalloc/deallocate.c b/src/plugins/slurmctld/dynalloc/deallocate.c
index 8ed0b29a886..81cf05a40fb 100644
--- a/src/plugins/slurmctld/dynalloc/deallocate.c
+++ b/src/plugins/slurmctld/dynalloc/deallocate.c
@@ -50,7 +50,17 @@
 #include "argv.h"
 #include "constants.h"
 
-int deallocate(slurm_fd_t new_fd, const char *msg)
+/**
+ * deallocate the resources for slurm jobs.
+ *
+ * the deallocate msg can be like "deallocate slurm_jobid=123
+ * job_return_code=0:slurm_jobid=124 job_return_code=0"
+ *
+ * IN:
+ *	msg: the deallocate msg
+ *
+ */
+extern void deallocate(const char *msg)
 {
 	char **jobid_argv = NULL, **tmp_jobid_argv;
 	char *pos = NULL;
diff --git a/src/plugins/slurmctld/dynalloc/deallocate.h b/src/plugins/slurmctld/dynalloc/deallocate.h
index 36e6162eaa6..3898e0795a8 100644
--- a/src/plugins/slurmctld/dynalloc/deallocate.h
+++ b/src/plugins/slurmctld/dynalloc/deallocate.h
@@ -57,6 +57,16 @@
 
 #include "msg.h"
 
-extern int deallocate(slurm_fd_t new_fd, const char *msg);
+/**
+ * deallocate the resources for slurm jobs.
+ *
+ * the deallocate msg can be like "deallocate slurm_jobid=123
+ * job_return_code=0:slurm_jobid=124 job_return_code=0"
+ *
+ * IN:
+ *	msg: the deallocate msg
+ *
+ */
+extern void deallocate(const char *msg);
 
 #endif /* DYNALLOC_DEALLOCATE_H_ */
diff --git a/src/plugins/slurmctld/dynalloc/info.c b/src/plugins/slurmctld/dynalloc/info.c
index 5851fca5fdb..b64da9ea069 100644
--- a/src/plugins/slurmctld/dynalloc/info.c
+++ b/src/plugins/slurmctld/dynalloc/info.c
@@ -163,7 +163,7 @@ hostlist_t get_available_host_list_system_m(void)
  *
  *	Note: the return result should be free(str)
  */
-char* get_available_host_list_range_sytem_m()
+char* get_available_host_list_range_sytem_m(void)
 {
 	hostlist_t hostlist = NULL;
 	char *range = NULL;
@@ -175,10 +175,10 @@ char* get_available_host_list_range_sytem_m()
 }
 
 /**
- *	get available node list within a given node list
+ *	get available node list within a given node list range
  *
  *	IN:
- *		node_list: the given node list
+ *		node_list: the given node list range
  *	OUT Parameter:
  *	RET OUT
  *		available node list
@@ -220,7 +220,7 @@ hostlist_t choose_available_from_node_list_m(const char *node_list)
  *	OUT Parameter:
  *	RET OUT
  *		the subset node range, NULL if the node number of subset is
- *		larger than the node number of host_name_list
+ *		larger than the node number in host_name_list
  *
  *	Note: the return should be free(str)
  */
@@ -263,53 +263,3 @@ char* get_hostlist_subset_m(const char *host_name_list, uint16_t node_num)
 	slurm_hostlist_destroy(hostlist);
 	return range;
 }
-
-/**
- *	transform nodelist with regular expression into
- *	comma seperated nodelist, like:
- *	host[2-3] will be host2,host3
- *	host[3,5] will be host3,host5
- *
- *	IN:
- *		node_list: the given node_list
- *	OUT Parameter:
- *	RET OUT
- *		comma seperated nodelist
- *
- *	Note: the return should be free(str)
- */
-char* seperate_nodelist_with_comma_m(const char *node_list)
-{
-	char *parsed_nodelist = NULL;
-	char *tmp = NULL;
-	char *nodename = NULL;
-	hostlist_t given_hl = NULL;
-
-	if (NULL == node_list)
-		return NULL;
-
-	given_hl = slurm_hostlist_create(node_list);
-
-	while ((nodename = slurm_hostlist_shift(given_hl))) {
-		if (NULL == parsed_nodelist)
-			parsed_nodelist = strdup(nodename);
-		else {
-			if (asprintf(&tmp, "%s,%s", parsed_nodelist,
-				     nodename) < 0) {
-				error("slurmctld/dynalloc: asprintf(%s,%s): %m",
-				      parsed_nodelist, nodename);
-
-			}
-			free(parsed_nodelist);
-			parsed_nodelist = tmp;
-			/* tmp should not be freed*/
-		}
-		/* Note: to free memory after slurm_hostlist_shift(),
-		 * 	remember to use free(str), not xfree(str)
-		 */
-		free(nodename);
-	}
-
-	slurm_hostlist_destroy(given_hl);
-	return parsed_nodelist;
-}
diff --git a/src/plugins/slurmctld/dynalloc/info.h b/src/plugins/slurmctld/dynalloc/info.h
index 1f4d900fdd2..b3cb9ff6c72 100644
--- a/src/plugins/slurmctld/dynalloc/info.h
+++ b/src/plugins/slurmctld/dynalloc/info.h
@@ -52,6 +52,7 @@
 #endif  /*  HAVE_CONFIG_H */
 
 #include "slurm/slurm.h"
+
 /**
  *	get total number of nodes and slots in slurm.
  *
@@ -79,6 +80,8 @@ extern void get_free_nodes_slots(uint16_t *nodes, uint16_t *slots);
  *	OUT Parameter:
  *	RET OUT:
  *		hostlist_t: available node list in slurm
+ *
+ *	Note: the return result should be slurm_hostlist_destroy(hostlist)
  */
 extern hostlist_t get_available_host_list_system_m(void);
 
@@ -89,17 +92,21 @@ extern hostlist_t get_available_host_list_system_m(void);
  *	OUT Parameter:
  *	RET OUT:
  *		a string indicating the range of available node list in slurm
+ *
+ *	Note: the return result should be free(str)
  */
-extern char* get_available_host_list_range_sytem_m();
+extern char* get_available_host_list_range_sytem_m(void);
 
 /**
- *	get available node list within a given node list
+ *	get available node list within a given node list range
  *
  *	IN:
- *		node_list: the given node list
+ *		node_list: the given node list range
  *	OUT Parameter:
  *	RET OUT
  *		available node list
+ *
+ * Note: the return result should be slurm_hostlist_destroy(hostlist)
  */
 extern hostlist_t choose_available_from_node_list_m(const char *node_list);
 
@@ -112,22 +119,10 @@ extern hostlist_t choose_available_from_node_list_m(const char *node_list);
  *	OUT Parameter:
  *	RET OUT
  *		the subset node range, NULL if the node number of subset is
- *		larger than the node number of host_name_list
- */
-extern char* get_hostlist_subset_m(const char *host_name_list, uint16_t node_num);
-
-/**
- *	transform nodelist with regular expression into
- *	comma seperated nodelist, like:
- *	host[2-3] will be host2,host3
- *	host[3,5] will be host3,host5
+ *		larger than the node number in host_name_list
  *
- *	IN:
- *		node_list: the given node_list
- *	OUT Parameter:
- *	RET OUT
- *		comma seperated nodelist
+ *	Note: the return should be free(str)
  */
-extern char* seperate_nodelist_with_comma_m(const char *node_list);
+extern char* get_hostlist_subset_m(const char *host_name_list, uint16_t node_num);
 
 #endif /* DYNALLOC_INFO_H_ */
diff --git a/src/plugins/slurmctld/dynalloc/msg.c b/src/plugins/slurmctld/dynalloc/msg.c
index 921ed9e52be..1388d20bbd0 100644
--- a/src/plugins/slurmctld/dynalloc/msg.c
+++ b/src/plugins/slurmctld/dynalloc/msg.c
@@ -362,7 +362,7 @@ static void	_proc_msg(slurm_fd_t new_fd, char *msg)
 		} else if (0 == strncasecmp(msg, "allocate", 8)) {
 			allocate_job_op(new_fd, msg);
 		} else if (0 == strncasecmp(msg, "deallocate", 10)) {
-			deallocate(new_fd, msg);
+			deallocate(msg);
 		}
 	}
 	return;
-- 
GitLab