udev: fix gcc warnings
This commit is contained in:
parent
3e2147858f
commit
fc863deada
|
@ -138,7 +138,7 @@ static bool is_mounted(const char *device)
|
||||||
return mounted;
|
return mounted;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void info_scsi_cmd_err(struct udev *udev, char *cmd, int err)
|
static void info_scsi_cmd_err(struct udev *udev, const char *cmd, int err)
|
||||||
{
|
{
|
||||||
if (err == -1) {
|
if (err == -1) {
|
||||||
info(udev, "%s failed\n", cmd);
|
info(udev, "%s failed\n", cmd);
|
||||||
|
|
|
@ -418,8 +418,9 @@ int main(int argc, char **argv)
|
||||||
/* Keymap file argument is a filename */
|
/* Keymap file argument is a filename */
|
||||||
/* Open override file if present, otherwise default file */
|
/* Open override file if present, otherwise default file */
|
||||||
char keymap_path[PATH_MAX];
|
char keymap_path[PATH_MAX];
|
||||||
|
FILE *f;
|
||||||
snprintf(keymap_path, sizeof(keymap_path), "%s%s", SYSCONFDIR "/udev/keymaps/", filearg);
|
snprintf(keymap_path, sizeof(keymap_path), "%s%s", SYSCONFDIR "/udev/keymaps/", filearg);
|
||||||
FILE *f = fopen(keymap_path, "r");
|
f = fopen(keymap_path, "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
merge_table(fd, f);
|
merge_table(fd, f);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -171,7 +171,7 @@ ssize_t udev_queue_skip_devpath(FILE *queue_file)
|
||||||
unsigned short int len;
|
unsigned short int len;
|
||||||
|
|
||||||
if (fread(&len, sizeof(unsigned short int), 1, queue_file) == 1) {
|
if (fread(&len, sizeof(unsigned short int), 1, queue_file) == 1) {
|
||||||
char devpath[len];
|
char *devpath = alloca(len);
|
||||||
|
|
||||||
/* use fread to skip, fseek might drop buffered data */
|
/* use fread to skip, fseek might drop buffered data */
|
||||||
if (fread(devpath, 1, len, queue_file) == len)
|
if (fread(devpath, 1, len, queue_file) == len)
|
||||||
|
@ -197,7 +197,7 @@ ssize_t udev_queue_read_devpath(FILE *queue_file, char *devpath, size_t size)
|
||||||
/* if devpath was too long, skip unread characters */
|
/* if devpath was too long, skip unread characters */
|
||||||
if (read_bytes != len) {
|
if (read_bytes != len) {
|
||||||
unsigned short int skip_bytes = len - read_bytes;
|
unsigned short int skip_bytes = len - read_bytes;
|
||||||
char buf[skip_bytes];
|
char *buf = alloca(skip_bytes);
|
||||||
|
|
||||||
if (fread(buf, 1, skip_bytes, queue_file) != skip_bytes)
|
if (fread(buf, 1, skip_bytes, queue_file) != skip_bytes)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -116,11 +116,11 @@ int util_delete_path(struct udev *udev, const char *path)
|
||||||
uid_t util_lookup_user(struct udev *udev, const char *user)
|
uid_t util_lookup_user(struct udev *udev, const char *user)
|
||||||
{
|
{
|
||||||
char *endptr;
|
char *endptr;
|
||||||
size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
|
|
||||||
char buf[buflen];
|
|
||||||
struct passwd pwbuf;
|
struct passwd pwbuf;
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
|
size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||||
|
char *buf = alloca(buflen);
|
||||||
|
|
||||||
if (strcmp(user, "root") == 0)
|
if (strcmp(user, "root") == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -141,11 +141,11 @@ uid_t util_lookup_user(struct udev *udev, const char *user)
|
||||||
gid_t util_lookup_group(struct udev *udev, const char *group)
|
gid_t util_lookup_group(struct udev *udev, const char *group)
|
||||||
{
|
{
|
||||||
char *endptr;
|
char *endptr;
|
||||||
size_t buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
|
|
||||||
char *buf;
|
|
||||||
struct group grbuf;
|
struct group grbuf;
|
||||||
struct group *gr;
|
struct group *gr;
|
||||||
gid_t gid = 0;
|
gid_t gid = 0;
|
||||||
|
size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
|
||||||
|
char *buf = alloca(buflen);
|
||||||
|
|
||||||
if (strcmp(group, "root") == 0)
|
if (strcmp(group, "root") == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -28,19 +28,22 @@
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
int mtd_fd;
|
||||||
|
int error;
|
||||||
|
mtd_info_t mtd_info;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
printf("usage: mtd_probe /dev/mtd[n]\n");
|
printf("usage: mtd_probe /dev/mtd[n]\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mtd_fd = open(argv[1], O_RDONLY);
|
mtd_fd = open(argv[1], O_RDONLY);
|
||||||
if (mtd_fd == -1) {
|
if (mtd_fd == -1) {
|
||||||
perror("open");
|
perror("open");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtd_info_t mtd_info;
|
error = ioctl(mtd_fd, MEMGETINFO, &mtd_info);
|
||||||
int error = ioctl(mtd_fd, MEMGETINFO, &mtd_info);
|
|
||||||
if (error == -1) {
|
if (error == -1) {
|
||||||
perror("ioctl");
|
perror("ioctl");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|
|
@ -36,7 +36,13 @@ static const uint8_t cis_signature[] = {
|
||||||
|
|
||||||
void probe_smart_media(int mtd_fd, mtd_info_t* info)
|
void probe_smart_media(int mtd_fd, mtd_info_t* info)
|
||||||
{
|
{
|
||||||
|
int sector_size;
|
||||||
|
int block_size;
|
||||||
|
int size_in_megs;
|
||||||
|
int spare_count;
|
||||||
char* cis_buffer = malloc(SM_SECTOR_SIZE);
|
char* cis_buffer = malloc(SM_SECTOR_SIZE);
|
||||||
|
int offset;
|
||||||
|
int cis_found = 0;
|
||||||
|
|
||||||
if (!cis_buffer)
|
if (!cis_buffer)
|
||||||
return;
|
return;
|
||||||
|
@ -44,11 +50,9 @@ void probe_smart_media(int mtd_fd, mtd_info_t* info)
|
||||||
if (info->type != MTD_NANDFLASH)
|
if (info->type != MTD_NANDFLASH)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
int sector_size = info->writesize;
|
sector_size = info->writesize;
|
||||||
int block_size = info->erasesize;
|
block_size = info->erasesize;
|
||||||
int size_in_megs = info->size / (1024 * 1024);
|
size_in_megs = info->size / (1024 * 1024);
|
||||||
int spare_count;
|
|
||||||
|
|
||||||
|
|
||||||
if (sector_size != SM_SECTOR_SIZE && sector_size != SM_SMALL_PAGE)
|
if (sector_size != SM_SECTOR_SIZE && sector_size != SM_SMALL_PAGE)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -66,13 +70,8 @@ void probe_smart_media(int mtd_fd, mtd_info_t* info)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int offset;
|
|
||||||
int cis_found = 0;
|
|
||||||
|
|
||||||
for (offset = 0 ; offset < block_size * spare_count ;
|
for (offset = 0 ; offset < block_size * spare_count ;
|
||||||
offset += sector_size) {
|
offset += sector_size) {
|
||||||
|
|
||||||
lseek(mtd_fd, SEEK_SET, offset);
|
lseek(mtd_fd, SEEK_SET, offset);
|
||||||
if (read(mtd_fd, cis_buffer, SM_SECTOR_SIZE) == SM_SECTOR_SIZE){
|
if (read(mtd_fd, cis_buffer, SM_SECTOR_SIZE) == SM_SECTOR_SIZE){
|
||||||
cis_found = 1;
|
cis_found = 1;
|
||||||
|
|
|
@ -164,6 +164,7 @@ const char *udev_builtin_name(enum udev_builtin_cmd cmd);
|
||||||
bool udev_builtin_run_once(enum udev_builtin_cmd cmd);
|
bool udev_builtin_run_once(enum udev_builtin_cmd cmd);
|
||||||
int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const char *command, bool test);
|
int udev_builtin_run(struct udev_device *dev, enum udev_builtin_cmd cmd, const char *command, bool test);
|
||||||
void udev_builtin_list(struct udev *udev);
|
void udev_builtin_list(struct udev *udev);
|
||||||
|
bool udev_builtin_validate(struct udev *udev);
|
||||||
int udev_builtin_add_property(struct udev_device *dev, bool test, const char *key, const char *val);
|
int udev_builtin_add_property(struct udev_device *dev, bool test, const char *key, const char *val);
|
||||||
|
|
||||||
/* udev logging */
|
/* udev logging */
|
||||||
|
|
Loading…
Reference in a new issue