mirror of
				https://github.com/alsa-project/alsa-lib.git
				synced 2025-11-03 09:01:52 -05:00 
			
		
		
		
	topology: implement shorter hexa uuid 00:00 parser
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
		
							parent
							
								
									07d779143b
								
							
						
					
					
						commit
						2947d83c13
					
				
					 1 changed files with 31 additions and 6 deletions
				
			
		| 
						 | 
					@ -22,8 +22,8 @@
 | 
				
			||||||
#include <ctype.h>
 | 
					#include <ctype.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define UUID_FORMAT "\
 | 
					#define UUID_FORMAT "\
 | 
				
			||||||
0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, \
 | 
					%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:\
 | 
				
			||||||
0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x"
 | 
					%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Get private data buffer of an element */
 | 
					/* Get private data buffer of an element */
 | 
				
			||||||
struct snd_soc_tplg_private *get_priv_data(struct tplg_elem *elem)
 | 
					struct snd_soc_tplg_private *get_priv_data(struct tplg_elem *elem)
 | 
				
			||||||
| 
						 | 
					@ -316,7 +316,6 @@ format2:
 | 
				
			||||||
				values++;
 | 
									values++;
 | 
				
			||||||
				s += 2;
 | 
									s += 2;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			s++;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		s++;
 | 
							s++;
 | 
				
			||||||
| 
						 | 
					@ -341,6 +340,32 @@ static int get_uuid(const char *str, unsigned char *uuid_le)
 | 
				
			||||||
	if (tmp == NULL)
 | 
						if (tmp == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (strchr(tmp, ':') == NULL)
 | 
				
			||||||
 | 
							goto data2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						s = strtok(tmp, ":");
 | 
				
			||||||
 | 
						while (s != NULL) {
 | 
				
			||||||
 | 
							errno = 0;
 | 
				
			||||||
 | 
							val = strtoul(s, NULL, 16);
 | 
				
			||||||
 | 
							if ((errno == ERANGE && val == ULONG_MAX)
 | 
				
			||||||
 | 
								|| (errno != 0 && val == 0)
 | 
				
			||||||
 | 
								|| (val > UCHAR_MAX)) {
 | 
				
			||||||
 | 
								SNDERR("invalid value for uuid");
 | 
				
			||||||
 | 
								ret = -EINVAL;
 | 
				
			||||||
 | 
								goto out;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							*(uuid_le + values) = (unsigned char)val;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							values++;
 | 
				
			||||||
 | 
							if (values >= 16)
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							s = strtok(NULL, ":");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					data2:
 | 
				
			||||||
	s = strtok(tmp, ",");
 | 
						s = strtok(tmp, ",");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (s != NULL) {
 | 
						while (s != NULL) {
 | 
				
			||||||
| 
						 | 
					@ -413,7 +438,7 @@ static int copy_data_hex(char *data, int off, const char *str, int width)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	p += off;
 | 
						p += off;
 | 
				
			||||||
	s = strtok(tmp, ",");
 | 
						s = strtok(tmp, ",:");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (s != NULL) {
 | 
						while (s != NULL) {
 | 
				
			||||||
		ret = write_hex(p, s, width);
 | 
							ret = write_hex(p, s, width);
 | 
				
			||||||
| 
						 | 
					@ -422,7 +447,7 @@ static int copy_data_hex(char *data, int off, const char *str, int width)
 | 
				
			||||||
			return ret;
 | 
								return ret;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		s = strtok(NULL, ",");
 | 
							s = strtok(NULL, ",:");
 | 
				
			||||||
		p += width;
 | 
							p += width;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue