@@ -131,7 +131,7 @@ static int esp_transport_read_internal(transport_ws_t *ws, char *buffer, int len
131131 return to_read ;
132132}
133133
134- static char * trimwhitespace (const char * str )
134+ static char * trimwhitespace (char * str )
135135{
136136 char * end ;
137137
@@ -141,19 +141,19 @@ static char *trimwhitespace(const char *str)
141141 }
142142
143143 if (* str == 0 ) {
144- return ( char * ) str ;
144+ return str ;
145145 }
146146
147147 // Trim trailing space
148- end = ( char * )( str + strlen (str ) - 1 ) ;
148+ end = str + strlen (str ) - 1 ;
149149 while (end > str && isspace ((unsigned char )* end )) {
150150 end -- ;
151151 }
152152
153153 // Write new null terminator
154- * (end + 1 ) = 0 ;
154+ * (end + 1 ) = '\0' ;
155155
156- return ( char * ) str ;
156+ return str ;
157157}
158158
159159static int get_http_status_code (const char * buffer )
@@ -162,11 +162,11 @@ static int get_http_status_code(const char *buffer)
162162 const char * found = strcasestr (buffer , http );
163163 char status_code [4 ];
164164 if (found ) {
165- found += sizeof (http )/ sizeof ( http [ 0 ]) - 1 ;
165+ found += sizeof (http ) - 1 ;
166166 found = strchr (found , ' ' );
167167 if (found ) {
168168 found ++ ;
169- strncpy (status_code , found , 4 );
169+ strncpy (status_code , found , 3 );
170170 status_code [3 ] = '\0' ;
171171 int code = atoi (status_code );
172172 ESP_LOGD (TAG , "HTTP status code is %d" , code );
@@ -176,14 +176,14 @@ static int get_http_status_code(const char *buffer)
176176 return -1 ;
177177}
178178
179- static char * get_http_header (const char * buffer , const char * key )
179+ static char * get_http_header (char * buffer , const char * key )
180180{
181181 char * found = strcasestr (buffer , key );
182182 if (found ) {
183183 found += strlen (key );
184184 char * found_end = strstr (found , "\r\n" );
185185 if (found_end ) {
186- found_end [ 0 ] = 0 ; // terminal string
186+ * found_end = '\0' ; // terminal string
187187
188188 return trimwhitespace (found );
189189 }
0 commit comments