From: Peter Stokes <linux@dadeos.co.uk>
To: alsa-devel@alsa-project.org
Subject: [PATCH 1/2] Arcam AV Control Plugin Updates
Date: Sat, 21 Feb 2009 16:59:52 +0000 [thread overview]
Message-ID: <200902211659.52723.linux@dadeos.co.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 113 bytes --]
arcam_av: Remove incorrect usage of the static SHM ID variable
Signed-off-by: Peter Stokes <linux@dadeos.co.uk>
[-- Attachment #2: arcam_av_remove_static.patch --]
[-- Type: text/x-diff, Size: 2142 bytes --]
diff --git a/arcam-av/arcam_av.c b/arcam-av/arcam_av.c
index 81e72e9..0491fc6 100644
--- a/arcam-av/arcam_av.c
+++ b/arcam-av/arcam_av.c
@@ -329,39 +329,34 @@ static void arcam_av_state_query(int fd)
}
-static int arcam_av_state_shm_id = -1;
-
arcam_av_state_t* arcam_av_state_attach(const char* port)
{
arcam_av_state_t* state;
+ struct stat port_stat;
+ key_t ipc_key;
+ int shmid, shmflg;
+ struct shmid_ds shm_stat;
- if (arcam_av_state_shm_id < 0) {
- struct stat port_stat;
- key_t ipc_key;
- int shmflg;
- struct shmid_ds shm_stat;
-
- if (stat(port, &port_stat))
- return NULL;
+ if (stat(port, &port_stat))
+ return NULL;
- ipc_key = ftok(port, 'A');
- if (ipc_key < 0)
- return NULL;
+ ipc_key = ftok(port, 'A');
+ if (ipc_key < 0)
+ return NULL;
- shmflg = IPC_CREAT | (port_stat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
- arcam_av_state_shm_id = shmget(ipc_key, sizeof(arcam_av_state_t), shmflg);
- if (arcam_av_state_shm_id < 0)
- return NULL;
+ shmflg = IPC_CREAT | (port_stat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
+ shmid = shmget(ipc_key, sizeof(arcam_av_state_t), shmflg);
+ if (shmid < 0)
+ return NULL;
- if (shmctl(arcam_av_state_shm_id, IPC_STAT, &shm_stat))
- return NULL;
+ if (shmctl(shmid, IPC_STAT, &shm_stat))
+ return NULL;
- shm_stat.shm_perm.uid = port_stat.st_uid;
- shm_stat.shm_perm.gid = port_stat.st_gid;
- shmctl(arcam_av_state_shm_id, IPC_SET, &shm_stat);
- }
+ shm_stat.shm_perm.uid = port_stat.st_uid;
+ shm_stat.shm_perm.gid = port_stat.st_gid;
+ shmctl(shmid, IPC_SET, &shm_stat);
- state = shmat(arcam_av_state_shm_id, NULL, 0);
+ state = shmat(shmid, NULL, 0);
return (state == (void*)-1) ? NULL : state;
}
@@ -369,20 +364,7 @@ arcam_av_state_t* arcam_av_state_attach(const char* port)
int arcam_av_state_detach(arcam_av_state_t* state)
{
- struct shmid_ds shm_stat;
-
- if (shmdt(state))
- return -1;
-
- if (shmctl(arcam_av_state_shm_id, IPC_STAT, &shm_stat))
- return -1;
-
- if (!shm_stat.shm_nattch) {
- shmctl(arcam_av_state_shm_id, IPC_RMID, NULL);
- arcam_av_state_shm_id = -1;
- }
-
- return 0;
+ return shmdt(state);
}
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
reply other threads:[~2009-02-21 17:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200902211659.52723.linux@dadeos.co.uk \
--to=linux@dadeos.co.uk \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.