diff mbox series

option handling: remove unneeded seek_str != NULL check

Message ID 20180110152649.19635-1-christian.storm@siemens.com
State Accepted
Headers show
Series option handling: remove unneeded seek_str != NULL check | expand

Commit Message

Storm, Christian Jan. 10, 2018, 3:26 p.m. UTC
The comparison of array seek_str != NULL is always true,
hence remove it.

Signed-off-by: Christian Storm <christian.storm@siemens.com>
---
 corelib/lua_interface.c | 2 +-
 parser/parse_external.c | 2 +-
 parser/parser.c         | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

Comments

Stefano Babic Jan. 10, 2018, 3:40 p.m. UTC | #1
On 10/01/2018 16:26, Christian Storm wrote:
> The comparison of array seek_str != NULL is always true,
> hence remove it.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  corelib/lua_interface.c | 2 +-
>  parser/parse_external.c | 2 +-
>  parser/parser.c         | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
> index eba9884..26f10f6 100644
> --- a/corelib/lua_interface.c
> +++ b/corelib/lua_interface.c
> @@ -252,7 +252,7 @@ static void lua_string_to_img(struct img_type *img, const char *key,
>  		strncpy(seek_str, value,
>  			sizeof(seek_str));
>  		/* convert the offset handling multiplicative suffixes */
> -		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
> +		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
>  			errno = 0;
>  			img->seek = ustrtoull(seek_str, &endp, 0);
>  			if (seek_str == endp || (img->seek == ULLONG_MAX && \
> diff --git a/parser/parse_external.c b/parser/parse_external.c
> index b876c07..60c2961 100644
> --- a/parser/parse_external.c
> +++ b/parser/parse_external.c
> @@ -83,7 +83,7 @@ static void sw_append_stream(struct img_type *img, const char *key,
>  		strncpy(seek_str, value,
>  			sizeof(seek_str));
>  		/* convert the offset handling multiplicative suffixes */
> -		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
> +		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
>  			errno = 0;
>  			img->seek = ustrtoull(seek_str, &endp, 0);
>  			if (seek_str == endp || (img->seek == ULLONG_MAX && \
> diff --git a/parser/parser.c b/parser/parser.c
> index 44cd0fe..3a1d6a5 100644
> --- a/parser/parser.c
> +++ b/parser/parser.c
> @@ -456,7 +456,7 @@ static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua
>  		get_hash_value(p, elem, image->sha256);
>  
>  		/* convert the offset handling multiplicative suffixes */
> -		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
> +		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
>  			errno = 0;
>  			image->seek = ustrtoull(seek_str, &endp, 0);
>  			if (seek_str == endp || (image->seek == ULLONG_MAX && \
> 

Reviewed-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic
Stefano Babic Jan. 11, 2018, 1:29 p.m. UTC | #2
Hi Christian,

On 10/01/2018 16:26, Christian Storm wrote:
> The comparison of array seek_str != NULL is always true,
> hence remove it.
> 
> Signed-off-by: Christian Storm <christian.storm@siemens.com>
> ---
>  corelib/lua_interface.c | 2 +-
>  parser/parse_external.c | 2 +-
>  parser/parser.c         | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
> index eba9884..26f10f6 100644
> --- a/corelib/lua_interface.c
> +++ b/corelib/lua_interface.c
> @@ -252,7 +252,7 @@ static void lua_string_to_img(struct img_type *img, const char *key,
>  		strncpy(seek_str, value,
>  			sizeof(seek_str));
>  		/* convert the offset handling multiplicative suffixes */
> -		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
> +		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
>  			errno = 0;
>  			img->seek = ustrtoull(seek_str, &endp, 0);
>  			if (seek_str == endp || (img->seek == ULLONG_MAX && \
> diff --git a/parser/parse_external.c b/parser/parse_external.c
> index b876c07..60c2961 100644
> --- a/parser/parse_external.c
> +++ b/parser/parse_external.c
> @@ -83,7 +83,7 @@ static void sw_append_stream(struct img_type *img, const char *key,
>  		strncpy(seek_str, value,
>  			sizeof(seek_str));
>  		/* convert the offset handling multiplicative suffixes */
> -		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
> +		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
>  			errno = 0;
>  			img->seek = ustrtoull(seek_str, &endp, 0);
>  			if (seek_str == endp || (img->seek == ULLONG_MAX && \
> diff --git a/parser/parser.c b/parser/parser.c
> index 44cd0fe..3a1d6a5 100644
> --- a/parser/parser.c
> +++ b/parser/parser.c
> @@ -456,7 +456,7 @@ static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua
>  		get_hash_value(p, elem, image->sha256);
>  
>  		/* convert the offset handling multiplicative suffixes */
> -		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
> +		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
>  			errno = 0;
>  			image->seek = ustrtoull(seek_str, &endp, 0);
>  			if (seek_str == endp || (image->seek == ULLONG_MAX && \
> 

Applied to -master, thanks !

Best regards,
Stefano Babic
diff mbox series

Patch

diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index eba9884..26f10f6 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -252,7 +252,7 @@  static void lua_string_to_img(struct img_type *img, const char *key,
 		strncpy(seek_str, value,
 			sizeof(seek_str));
 		/* convert the offset handling multiplicative suffixes */
-		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
+		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
 			errno = 0;
 			img->seek = ustrtoull(seek_str, &endp, 0);
 			if (seek_str == endp || (img->seek == ULLONG_MAX && \
diff --git a/parser/parse_external.c b/parser/parse_external.c
index b876c07..60c2961 100644
--- a/parser/parse_external.c
+++ b/parser/parse_external.c
@@ -83,7 +83,7 @@  static void sw_append_stream(struct img_type *img, const char *key,
 		strncpy(seek_str, value,
 			sizeof(seek_str));
 		/* convert the offset handling multiplicative suffixes */
-		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
+		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
 			errno = 0;
 			img->seek = ustrtoull(seek_str, &endp, 0);
 			if (seek_str == endp || (img->seek == ULLONG_MAX && \
diff --git a/parser/parser.c b/parser/parser.c
index 44cd0fe..3a1d6a5 100644
--- a/parser/parser.c
+++ b/parser/parser.c
@@ -456,7 +456,7 @@  static int parse_images(parsertype p, void *cfg, struct swupdate_cfg *swcfg, lua
 		get_hash_value(p, elem, image->sha256);
 
 		/* convert the offset handling multiplicative suffixes */
-		if (seek_str != NULL && strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
+		if (strnlen(seek_str, MAX_SEEK_STRING_SIZE) != 0) {
 			errno = 0;
 			image->seek = ustrtoull(seek_str, &endp, 0);
 			if (seek_str == endp || (image->seek == ULLONG_MAX && \