rem: for (n_scsi_units = 0; device_str[n_scsi_units] != NULL && devices[n_scsi_units] != NULL; n_scsi_units++) {
add: for (n_units = 0; device_str[n_units] != NULL && devices[n_units] != NULL; n_units++) {
context: linux_scan (gboolean recorder_only){	char **device_str, **devices;	char **cdrom_info;	struct scsi_unit *scsi_units;	struct cdrom_unit *cdroms;	char *p, *t;	int n_scsi_units, n_cdroms, i, j;	int fd;	GList *cdroms_list;	/* Open /dev/sg0 to force loading of the sg module if not loaded yet */	fd = open ("/dev/sg0", O_RDONLY);	if (fd != -1) {		close (fd);	}	devices = read_lines ("/proc/scsi/sg/devices");	if (devices != NULL) {		device_str = read_lines ("/proc/scsi/sg/device_strs");		if (device_str == NULL) {			g_warning ("Can't read /proc/scsi/sg/device_strs");			g_strfreev (devices);			return NULL;		}		/* Count the number of scsi units, DO NOT REMOVE */		for (n_scsi_units = 0;		     device_str[n_scsi_units] != NULL && devices[n_scsi_units] != NULL;		     n_scsi_units++) {			/* Nothing */		}		scsi_units = g_new0 (struct scsi_unit, n_scsi_units);		for (i = 0; i < n_scsi_units; i++) {			parse_sg_line (device_str[i], devices[i], &scsi_units[i]);		}		g_strfreev (device_str);		g_strfreev (devices);	} else {		scsi_units = NULL;		n_scsi_units = 0;	}	cdrom_info = read_lines ("/proc/sys/dev/cdrom/info");	if (cdrom_info == NULL || cdrom_info[0] == NULL || cdrom_info[1] == NULL) {		g_warning ("Couldn't read /proc/sys/dev/cdrom/info");		g_free (scsi_units);		return NULL;	}	if (!g_str_has_prefix (cdrom_info[2], "drive name:\t")) {		g_free (scsi_units);		return NULL;	}	p = cdrom_info[2] + strlen ("drive name:\t");	while (*p == '\t') {		p++;	}	n_cdroms = count_strings (p);	cdroms = g_new0 (struct cdrom_unit, n_cdroms);	for (j = 0; j < n_cdroms; j++) {		t = strchr (p, '\t');		if (t != NULL) {			*t = 0;		}		cdroms[j].device = get_cd_device_file (p);		if (t != NULL) {			p = t + 1;		}	}	for (i = 3; cdrom_info[i] != NULL; i++) {		if (g_str_has_prefix (cdrom_info[i], "Can write CD-R:")) {			p = cdrom_info[i] + strlen ("Can write CD-R:");			while (*p == '\t') {				p++;			}			for (j = 0; j < n_cdroms; j++) {				cdroms[j].can_write_cdr = *p++ == '1';				/* Skip tab */				p++;			}		}		if (g_str_has_prefix (cdrom_info[i], "Can write CD-RW:")) {			p = cdrom_info[i] + strlen ("Can write CD-RW:");			while (*p == '\t') {				p++;			}			for (j = 0; j < n_cdroms; j++) {				cdroms[j].can_write_cdrw = *p++ == '1';				/* Skip tab */				p++;			}		}		if (g_str_has_prefix (cdrom_info[i], "Can write DVD-R:")) {			p = cdrom_info[i] + strlen ("Can write DVD-R:");			while (*p == '\t') {				p++;			}			for (j = 0; j < n_cdroms; j++) {				cdroms[j].can_write_dvdr = *p++ == '1';				/* Skip tab */				p++;			}		}		if (g_str_has_prefix (cdrom_info[i], "Can write DVD-RAM:")) {			p = cdrom_info[i] + strlen ("Can write DVD-RAM:");			while (*p == '\t') {				p++;			}			for (j = 0; j < n_cdroms; j++) {				cdroms[j].can_write_dvdram = *p++ == '1';				/* Skip tab */				p++;			}		}		if (g_str_has_prefix (cdrom_info[i], "Can read DVD:")) {			p = cdrom_info[i] + strlen ("Can read DVD:");			while (*p == '\t') {				p++;			}			for (j = 0; j < n_cdroms; j++) {				cdroms[j].can_read_dvd = *p++ == '1';				/* Skip tab */				p++;			}		}		if (g_str_has_prefix (cdrom_info[i], "drive speed:")) {			p = cdrom_info[i] + strlen ("drive speed:");			while (*p == '\t') {				p++;			}			for (j = 0; j < n_cdroms; j++) {  				cdroms[j].speed = atoi (p);				/* Skip tab */				p++;			}		}	}	g_strfreev (cdrom_info);	cdroms_list = NULL;	for (i = 0; i < n_cdroms; i++) {		if (cdroms[i].can_write_cdr ||		    cdroms[i].can_write_cdrw ||		    cdroms[i].can_write_dvdr ||		    cdroms[i].can_write_dvdram) {			cdroms_list = add_linux_cd_recorder (cdroms_list,					&cdroms[i], scsi_units, n_scsi_units);		} else if (!recorder_only) {			cdroms_list = add_linux_cd_drive (cdroms_list,					&cdroms[i], scsi_units, n_scsi_units);		}	}	g_free (scsi_units);	g_free (cdroms);	return cdroms_list;}