mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	spa: use errno values in warnings
Propagate the errno values from syscalls and use them in the warning messages to give info about what is going on.
This commit is contained in:
		
							parent
							
								
									72b41e5067
								
							
						
					
					
						commit
						151a2f0dea
					
				
					 1 changed files with 16 additions and 17 deletions
				
			
		| 
						 | 
					@ -519,21 +519,19 @@ int get_phc_index(struct spa_system *s, const char *name) {
 | 
				
			||||||
	info.cmd = ETHTOOL_GET_TS_INFO;
 | 
						info.cmd = ETHTOOL_GET_TS_INFO;
 | 
				
			||||||
	strncpy(ifr.ifr_name, name, IFNAMSIZ - 1);
 | 
						strncpy(ifr.ifr_name, name, IFNAMSIZ - 1);
 | 
				
			||||||
	ifr.ifr_data = (char *) &info;
 | 
						ifr.ifr_data = (char *) &info;
 | 
				
			||||||
	fd = socket(AF_INET, SOCK_DGRAM, 0);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (fd < 0) {
 | 
						fd = socket(AF_INET, SOCK_DGRAM, 0);
 | 
				
			||||||
		return -1;
 | 
						if (fd < 0)
 | 
				
			||||||
	}
 | 
							return -errno;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = spa_system_ioctl(s, fd, SIOCETHTOOL, &ifr);
 | 
						err = spa_system_ioctl(s, fd, SIOCETHTOOL, &ifr);
 | 
				
			||||||
	close(fd);
 | 
						close(fd);
 | 
				
			||||||
	if (err < 0) {
 | 
						if (err < 0)
 | 
				
			||||||
		return err;
 | 
							return -errno;
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return info.phc_index;
 | 
						return info.phc_index;
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
	return -1;
 | 
						return -ENOTSUP;
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -611,24 +609,25 @@ impl_init(const struct spa_handle_factory *factory,
 | 
				
			||||||
			this->clock_fd = open(s, O_RDWR);
 | 
								this->clock_fd = open(s, O_RDWR);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (this->clock_fd == -1) {
 | 
								if (this->clock_fd == -1) {
 | 
				
			||||||
				spa_log_warn(this->log, "failed to open clock device '%s'", s);
 | 
									spa_log_warn(this->log, "failed to open clock device '%s': %m", s);
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				this->props.clock_id = FD_TO_CLOCKID(this->clock_fd);
 | 
									this->props.clock_id = FD_TO_CLOCKID(this->clock_fd);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else if (spa_streq(k, "clock.interface") && this->clock_fd < 0) {
 | 
							} else if (spa_streq(k, "clock.interface") && this->clock_fd < 0) {
 | 
				
			||||||
			int phc_index = get_phc_index(this->data_system, s);
 | 
								int phc_index = get_phc_index(this->data_system, s);
 | 
				
			||||||
			if (phc_index < 0) {
 | 
								if (phc_index < 0) {
 | 
				
			||||||
				spa_log_warn(this->log, "failed to get phc device index for interface '%s'", s);
 | 
									spa_log_warn(this->log, "failed to get phc device index for interface '%s': %s",
 | 
				
			||||||
 | 
											s, spa_strerror(phc_index));
 | 
				
			||||||
			} else {
 | 
								} else {
 | 
				
			||||||
				char dev[19];
 | 
									char dev[19];
 | 
				
			||||||
				spa_scnprintf(dev, sizeof(dev), "/dev/ptp%d", phc_index);
 | 
									spa_scnprintf(dev, sizeof(dev), "/dev/ptp%d", phc_index);
 | 
				
			||||||
				this->clock_fd = open(dev, O_RDWR);
 | 
									this->clock_fd = open(dev, O_RDONLY);
 | 
				
			||||||
			}
 | 
									if (this->clock_fd == -1) {
 | 
				
			||||||
 | 
										spa_log_warn(this->log, "failed to open clock device '%s' "
 | 
				
			||||||
			if (this->clock_fd == -1) {
 | 
												"for interface '%s': %m", dev, s);
 | 
				
			||||||
				spa_log_warn(this->log, "failed to open clock device '%s'", s);
 | 
									} else {
 | 
				
			||||||
			} else {
 | 
										this->props.clock_id = FD_TO_CLOCKID(this->clock_fd);
 | 
				
			||||||
				this->props.clock_id = FD_TO_CLOCKID(this->clock_fd);
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else if (spa_streq(k, "freewheel.wait")) {
 | 
							} else if (spa_streq(k, "freewheel.wait")) {
 | 
				
			||||||
			this->props.freewheel_wait = atoi(s);
 | 
								this->props.freewheel_wait = atoi(s);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue