Skip to content

Commit

Permalink
constantify su_context* arg & small cosmetic fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
git-core committed Jan 29, 2012
1 parent 067da4e commit 3352996
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static const int VAL_INTEGER = 1;

static const int START_SUCCESS = 0;

int send_intent(struct su_context *ctx,
int send_intent(const struct su_context *ctx,
const char *socket_path, int allow, const char *action)
{
sp<IServiceManager> sm = defaultServiceManager();
Expand Down
8 changes: 3 additions & 5 deletions db.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@

#include "su.h"

// { int* pint; pint=(int*)data; ++(*pint); }

static sqlite3 *db_init()
static sqlite3 *db_init(void)
{
sqlite3 *db;
int rc;
Expand All @@ -41,7 +39,7 @@ static sqlite3 *db_init()
return db;
}

static int db_check(sqlite3 *db, struct su_context *ctx)
static int db_check(sqlite3 *db, const struct su_context *ctx)
{
char sql[4096];
char *zErrmsg;
Expand Down Expand Up @@ -86,7 +84,7 @@ static int db_check(sqlite3 *db, struct su_context *ctx)
return allow;
}

int database_check(struct su_context *ctx)
int database_check(const struct su_context *ctx)
{
sqlite3 *db;
int dballow;
Expand Down
6 changes: 3 additions & 3 deletions su.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ static int socket_accept(int serv_fd)
return fd;
}

static int socket_send_request(int fd, struct su_context *ctx)
static int socket_send_request(int fd, const struct su_context *ctx)
{
size_t len;
size_t bin_size, cmd_size;
Expand Down Expand Up @@ -268,7 +268,7 @@ static void usage(int status)
exit(status);
}

static void deny(struct su_context *ctx)
static void deny(const struct su_context *ctx)
{
char *cmd = get_command(&ctx->to);

Expand All @@ -278,7 +278,7 @@ static void deny(struct su_context *ctx)
exit(EXIT_FAILURE);
}

static void allow(struct su_context *ctx)
static void allow(const struct su_context *ctx)
{
char *arg0;
int argc, err;
Expand Down
16 changes: 8 additions & 8 deletions su.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ enum {
DB_ALLOW
};

extern int database_check(struct su_context *ctx);
extern int database_check(const struct su_context *ctx);

extern int send_intent(struct su_context *ctx,
extern int send_intent(const struct su_context *ctx,
const char *socket_path, int allow, const char *action);

static inline char *get_command(struct su_request *to)
static inline char *get_command(const struct su_request *to)
{
return (to->command) ? to->command : to->shell;
}

#if 0
#undef LOGE
#define LOGE(fmt,args...) fprintf(stderr, fmt , ## args )
#define LOGE(fmt,args...) fprintf(stderr, fmt, ##args)
#undef LOGD
#define LOGD(fmt,args...) fprintf(stderr, fmt , ## args )
#define LOGD(fmt,args...) fprintf(stderr, fmt, ##args)
#undef LOGW
#define LOGW(fmt,args...) fprintf(stderr, fmt , ## args )
#define LOGW(fmt,args...) fprintf(stderr, fmt, ##args)
#endif

#define PLOGE(fmt,args...) LOGE(fmt " failed with %d: %s" , ## args , errno, strerror(errno))
#define PLOGEV(fmt,err,args...) LOGE(fmt " failed with %d: %s" , ## args , err, strerror(err))
#define PLOGE(fmt,args...) LOGE(fmt " failed with %d: %s", ##args, errno, strerror(errno))
#define PLOGEV(fmt,err,args...) LOGE(fmt " failed with %d: %s", ##args, err, strerror(err))

#endif

0 comments on commit 3352996

Please sign in to comment.