Skip to content

Commit

Permalink
Rename g_file_open() to make r/w access explicit
Browse files Browse the repository at this point in the history
g_file_open() -> g_file_open_rw()
  • Loading branch information
iskunk committed May 18, 2022
1 parent ae0d70d commit 49d85d6
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion common/os_calls.c
Original file line number Diff line number Diff line change
Expand Up @@ -2162,7 +2162,7 @@ g_memcmp(const void *s1, const void *s2, int len)
/*****************************************************************************/
/* returns -1 on error, else return handle or file descriptor */
int
g_file_open(const char *file_name)
g_file_open_rw(const char *file_name)
{
#if defined(_WIN32)
return (int)CreateFileA(file_name, GENERIC_READ | GENERIC_WRITE,
Expand Down
2 changes: 1 addition & 1 deletion common/os_calls.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ int g_obj_wait(tintptr *read_objs, int rcount, tintptr *write_objs,
void g_random(char *data, int len);
int g_abs(int i);
int g_memcmp(const void *s1, const void *s2, int len);
int g_file_open(const char *file_name);
int g_file_open_rw(const char *file_name);
int g_file_open_ex(const char *file_name, int aread, int awrite,
int acreate, int atrunc);
int g_file_open_ro(const char *file_name);
Expand Down
2 changes: 1 addition & 1 deletion fontdump/fontdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ font_dump(void)
g_snprintf(filename, 255, "%s-%d.fv1", g_font_name, g_font_size);
msg("creating file %s", filename);
g_file_delete(filename);
fd = g_file_open(filename);
fd = g_file_open_rw(filename);
g_file_write(fd, "FNT1", 4);
strlen1 = g_strlen(g_font_name);
g_file_write(fd, g_font_name, strlen1);
Expand Down
2 changes: 1 addition & 1 deletion keygen/keygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ save_all(const char *e_data, int e_len, const char *n_data, int n_len,
}
}

fd = g_file_open(filename);
fd = g_file_open_rw(filename);

if (fd != -1)
{
Expand Down
2 changes: 1 addition & 1 deletion sesman/lock_uds.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ lock_uds(const char *sockname)
*p++ = '\0';

saved_umask = g_umask_hex(0x77);
fd = g_file_open(filename);
fd = g_file_open_rw(filename);
g_umask_hex(saved_umask);
if (fd < 0)
{
Expand Down
8 changes: 4 additions & 4 deletions sesman/sesman.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,15 +777,15 @@ main(int argc, char **argv)
g_file_close(1);
g_file_close(2);

if (g_file_open("/dev/null") < 0)
if (g_file_open_rw("/dev/null") < 0)
{
}

if (g_file_open("/dev/null") < 0)
if (g_file_open_rw("/dev/null") < 0)
{
}

if (g_file_open("/dev/null") < 0)
if (g_file_open_rw("/dev/null") < 0)
{
}
}
Expand Down Expand Up @@ -843,7 +843,7 @@ main(int argc, char **argv)
{
/* writing pid file */
char pid_s[32];
int fd = g_file_open(pid_file);
int fd = g_file_open_rw(pid_file);

if (-1 == fd)
{
Expand Down
10 changes: 5 additions & 5 deletions xrdp/xrdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ main(int argc, char **argv)
g_create_path(pid_file);

/* make sure we can write to pid file */
fd = g_file_open(pid_file); /* xrdp.pid */
fd = g_file_open_rw(pid_file); /* xrdp.pid */

if (fd == -1)
{
Expand Down Expand Up @@ -638,7 +638,7 @@ main(int argc, char **argv)
g_sleep(1000);
/* write the pid to file */
pid = g_getpid();
fd = g_file_open(pid_file); /* xrdp.pid */
fd = g_file_open_rw(pid_file); /* xrdp.pid */

if (fd == -1)
{
Expand All @@ -657,15 +657,15 @@ main(int argc, char **argv)
g_file_close(1);
g_file_close(2);

if (g_file_open("/dev/null") < 0)
if (g_file_open_rw("/dev/null") < 0)
{
}

if (g_file_open("/dev/null") < 0)
if (g_file_open_rw("/dev/null") < 0)
{
}

if (g_file_open("/dev/null") < 0)
if (g_file_open_rw("/dev/null") < 0)
{
}

Expand Down
2 changes: 1 addition & 1 deletion xrdp/xrdp_mm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2686,7 +2686,7 @@ xrdp_mm_dump_jpeg(struct xrdp_mm *self, XRDP_ENC_DATA_DONE *enc_done)
header.bytes_follow = enc_done->comp_bytes - (2 + pheader_bytes[0]);
if (ii == 0)
{
ii = g_file_open("/tmp/jpeg.beef.bin");
ii = g_file_open_rw("/tmp/jpeg.beef.bin");
if (ii == -1)
{
ii = 0;
Expand Down
12 changes: 6 additions & 6 deletions xrdp/xrdpwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ MyServiceMain(DWORD dwArgc, LPTSTR *lpszArgv)
// int fd;
// char text[256];

// fd = g_file_open("c:\\temp\\xrdp\\log.txt");
// fd = g_file_open_rw("c:\\temp\\xrdp\\log.txt");
// g_file_write(fd, "hi\r\n", 4);
//event_han = RegisterEventSource(0, "xrdp");
//log_event(event_han, "hi xrdp log");
Expand Down Expand Up @@ -546,7 +546,7 @@ main(int argc, char **argv)
if (!no_daemon)
{
/* make sure we can write to pid file */
fd = g_file_open(pid_file); /* xrdp.pid */
fd = g_file_open_rw(pid_file); /* xrdp.pid */

if (fd == -1)
{
Expand Down Expand Up @@ -586,17 +586,17 @@ main(int argc, char **argv)
g_file_close(0);
g_file_close(1);
g_file_close(2);
g_file_open("/dev/null");
g_file_open("/dev/null");
g_file_open("/dev/null");
g_file_open_rw("/dev/null");
g_file_open_rw("/dev/null");
g_file_open_rw("/dev/null");
/* end of daemonizing code */
}

if (!no_daemon)
{
/* write the pid to file */
pid = g_getpid();
fd = g_file_open(pid_file); /* xrdp.pid */
fd = g_file_open_rw(pid_file); /* xrdp.pid */

if (fd == -1)
{
Expand Down

0 comments on commit 49d85d6

Please sign in to comment.