diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-01-02 09:07:17 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-01-02 09:07:17 +0000 |
commit | 6d66fb308ab85bd9691d541764e683e6040cf724 (patch) | |
tree | 10b705921665cb7bafdd332ca53b8a943e13f0e5 /source3/printing | |
parent | c105c12d122e599fe57dde8b2b73c52231f0c1d2 (diff) | |
download | samba-6d66fb308ab85bd9691d541764e683e6040cf724.tar.gz samba-6d66fb308ab85bd9691d541764e683e6040cf724.tar.bz2 samba-6d66fb308ab85bd9691d541764e683e6040cf724.zip |
BIG patch...
This patch makes Samba compile cleanly with -Wwrite-strings.
- That is, all string literals are marked as 'const'. These strings are
always read only, this just marks them as such for passing to other functions.
What is most supprising is that I didn't need to change more than a few lines of code (all
in 'net', which got a small cleanup of net.h and extern variables). The rest
is just adding a lot of 'const'.
As far as I can tell, I have not added any new warnings - apart from making all
of tdbutil.c's function const (so they warn for adding that const string to
struct).
Andrew Bartlett
(This used to be commit 92a777d0eaa4fb3a1c7835816f93c6bdd456816d)
Diffstat (limited to 'source3/printing')
-rw-r--r-- | source3/printing/lpq_parse.c | 8 | ||||
-rw-r--r-- | source3/printing/nt_printing.c | 42 | ||||
-rw-r--r-- | source3/printing/printing.c | 12 |
3 files changed, 31 insertions, 31 deletions
diff --git a/source3/printing/lpq_parse.c b/source3/printing/lpq_parse.c index 59a844689c..4b91b8ac9a 100644 --- a/source3/printing/lpq_parse.c +++ b/source3/printing/lpq_parse.c @@ -20,7 +20,7 @@ #include "includes.h" -static char *Months[13] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", +static const char *Months[13] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Err"}; @@ -947,9 +947,9 @@ static BOOL parse_lpq_os2(char *line,print_queue_struct *buf,BOOL first) return(True); } -static char *stat0_strings[] = { "enabled", "online", "idle", "no entries", "free", "ready", NULL }; -static char *stat1_strings[] = { "offline", "disabled", "down", "off", "waiting", "no daemon", NULL }; -static char *stat2_strings[] = { "jam", "paper", "error", "responding", "not accepting", "not running", "turned off", NULL }; +static const char *stat0_strings[] = { "enabled", "online", "idle", "no entries", "free", "ready", NULL }; +static const char *stat1_strings[] = { "offline", "disabled", "down", "off", "waiting", "no daemon", NULL }; +static const char *stat2_strings[] = { "jam", "paper", "error", "responding", "not accepting", "not running", "turned off", NULL }; #ifdef DEVELOPER diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 31f480a4dd..f04992ac82 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -77,7 +77,7 @@ STANDARD_MAPPING printserver_std_mapping = { forms it wants and in the ORDER it wants them (note: DEVMODE papersize is an array index). Letter is always first, so (for the current code) additions always put things in the correct order. */ -static nt_forms_struct default_forms[] = { +static const nt_forms_struct default_forms[] = { {"Letter",0x1,0x34b5c,0x44368,0x0,0x0,0x34b5c,0x44368}, {"Letter Small",0x1,0x34b5c,0x44368,0x0,0x0,0x34b5c,0x44368}, {"Tabloid",0x1,0x44368,0x696b8,0x0,0x0,0x44368,0x696b8}, @@ -264,7 +264,7 @@ static BOOL upgrade_to_version_3(void) BOOL nt_printing_init(void) { static pid_t local_pid; - char *vstring = "INFO/version"; + const char *vstring = "INFO/version"; if (tdb_drivers && tdb_printers && tdb_forms && local_pid == sys_getpid()) return True; @@ -635,7 +635,7 @@ get the nt drivers list traverse the database and look-up the matching names ****************************************************************************/ -int get_ntdrivers(fstring **list, char *architecture, uint32 version) +int get_ntdrivers(fstring **list, const char *architecture, uint32 version) { int total=0; fstring short_archi; @@ -668,11 +668,11 @@ int get_ntdrivers(fstring **list, char *architecture, uint32 version) function to do the mapping between the long architecture name and the short one. ****************************************************************************/ -BOOL get_short_archi(char *short_archi, char *long_archi) +BOOL get_short_archi(char *short_archi, const char *long_archi) { struct table { - char *long_archi; - char *short_archi; + const char *long_archi; + const char *short_archi; }; struct table archi_table[]= @@ -1714,7 +1714,7 @@ static uint32 add_a_printer_driver_6(NT_PRINTER_DRIVER_INFO_LEVEL_6 *driver) /**************************************************************************** ****************************************************************************/ -static WERROR get_a_printer_driver_3_default(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, fstring driver, fstring arch) +static WERROR get_a_printer_driver_3_default(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, const char *driver, const char *arch) { NT_PRINTER_DRIVER_INFO_LEVEL_3 info; @@ -1741,7 +1741,7 @@ static WERROR get_a_printer_driver_3_default(NT_PRINTER_DRIVER_INFO_LEVEL_3 **in /**************************************************************************** ****************************************************************************/ -static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, fstring drivername, fstring arch, uint32 version) +static WERROR get_a_printer_driver_3(NT_PRINTER_DRIVER_INFO_LEVEL_3 **info_ptr, fstring drivername, const char *arch, uint32 version) { NT_PRINTER_DRIVER_INFO_LEVEL_3 driver; TDB_DATA kbuf, dbuf; @@ -2314,7 +2314,7 @@ int unpack_devicemode(NT_DEVICEMODE **nt_devmode, char *buf, int buflen) allocate and initialize a new slot in ***************************************************************************/ -static int add_new_printer_key( NT_PRINTER_DATA *data, char *name ) +static int add_new_printer_key( NT_PRINTER_DATA *data, const char *name ) { NT_PRINTER_KEY *d; int key_index; @@ -2348,7 +2348,7 @@ static int add_new_printer_key( NT_PRINTER_DATA *data, char *name ) search for a registry key name in the existing printer data ***************************************************************************/ -int lookup_printerkey( NT_PRINTER_DATA *data, char *name ) +int lookup_printerkey( NT_PRINTER_DATA *data, const char *name ) { int key_index = -1; int i; @@ -2376,7 +2376,7 @@ int lookup_printerkey( NT_PRINTER_DATA *data, char *name ) /**************************************************************************** ***************************************************************************/ -uint32 get_printer_subkeys( NT_PRINTER_DATA *data, char* key, fstring **subkeys ) +uint32 get_printer_subkeys( NT_PRINTER_DATA *data, const char* key, fstring **subkeys ) { int i, j; int key_len; @@ -2505,7 +2505,8 @@ static BOOL map_nt_printer_info2_to_dsspooler(NT_PRINTER_INFO_LEVEL_2 *info2) { REGVAL_CTR *ctr = NULL; fstring longname; - char *ascii_str; + char *allocated_string = NULL; + const char *ascii_str; int i; if ((i = lookup_printerkey(&info2->data, SPOOL_DSSPOOLER_KEY)) < 0) @@ -2518,10 +2519,9 @@ static BOOL map_nt_printer_info2_to_dsspooler(NT_PRINTER_INFO_LEVEL_2 *info2) get_myfullname(longname); map_sz_into_ctr(ctr, SPOOL_REG_SERVERNAME, longname); - asprintf(&ascii_str, "\\\\%s\\%s", longname, info2->sharename); - map_sz_into_ctr(ctr, SPOOL_REG_UNCNAME, ascii_str); - safe_free(ascii_str); - + asprintf(&allocated_string, "\\\\%s\\%s", longname, info2->sharename); + map_sz_into_ctr(ctr, SPOOL_REG_UNCNAME, allocated_string); + SAFE_FREE(allocated_string); map_dword_into_ctr(ctr, SPOOL_REG_VERSIONNUMBER, 4); map_sz_into_ctr(ctr, SPOOL_REG_DRIVERNAME, info2->drivername); @@ -2760,7 +2760,7 @@ BOOL is_printer_published(int snum, GUID *guid) /**************************************************************************** ***************************************************************************/ -WERROR delete_all_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key ) +WERROR delete_all_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key ) { NT_PRINTER_DATA *data; int i; @@ -2858,7 +2858,7 @@ WERROR delete_all_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key ) /**************************************************************************** ***************************************************************************/ -WERROR delete_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key, char *value ) +WERROR delete_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value ) { WERROR result = WERR_OK; int key_index; @@ -2885,7 +2885,7 @@ WERROR delete_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key, char *value /**************************************************************************** ***************************************************************************/ -WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key, char *value, +WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value, uint32 type, uint8 *data, int real_len ) { WERROR result = WERR_OK; @@ -2917,7 +2917,7 @@ WERROR add_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key, char *value, /**************************************************************************** ***************************************************************************/ -REGISTRY_VALUE* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, char *key, char *value ) +REGISTRY_VALUE* get_printer_data( NT_PRINTER_INFO_LEVEL_2 *p2, const char *key, const char *value ) { int key_index; @@ -3901,7 +3901,7 @@ uint32 add_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL driver, uint32 level) /**************************************************************************** ****************************************************************************/ WERROR get_a_printer_driver(NT_PRINTER_DRIVER_INFO_LEVEL *driver, uint32 level, - fstring drivername, fstring architecture, uint32 version) + fstring drivername, const char *architecture, uint32 version) { WERROR result; diff --git a/source3/printing/printing.c b/source3/printing/printing.c index cde1646107..711d99f394 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -165,7 +165,7 @@ static int get_queue_status(int, print_status_struct *); BOOL print_backend_init(void) { - char *sversion = "INFO/version"; + const char *sversion = "INFO/version"; pstring printing_path; int services = lp_numservices(); int snum; @@ -1291,10 +1291,10 @@ BOOL print_job_delete(struct current_user *user, int snum, uint32 jobid, WERROR *errcode = WERR_ACCESS_DENIED; /* BEGIN_ADMIN_LOG */ - sys_adminlog( LOG_ERR, (char *) - "Permission denied-- user not allowed to delete, \ + sys_adminlog( LOG_ERR, + "Permission denied-- user not allowed to delete, \ pause, or resume print job. User name: %s. Printer name: %s.", - uidtoname(user->uid), PRINTERNAME(snum) ); + uidtoname(user->uid), PRINTERNAME(snum) ); /* END_ADMIN_LOG */ return False; @@ -1356,7 +1356,7 @@ BOOL print_job_pause(struct current_user *user, int snum, uint32 jobid, WERROR * DEBUG(3, ("pause denied by security descriptor\n")); /* BEGIN_ADMIN_LOG */ - sys_adminlog( LOG_ERR, (char *) + sys_adminlog( LOG_ERR, "Permission denied-- user not allowed to delete, \ pause, or resume print job. User name: %s. Printer name: %s.", uidtoname(user->uid), PRINTERNAME(snum) ); @@ -1407,7 +1407,7 @@ BOOL print_job_resume(struct current_user *user, int snum, uint32 jobid, WERROR *errcode = WERR_ACCESS_DENIED; /* BEGIN_ADMIN_LOG */ - sys_adminlog( LOG_ERR, (char *) + sys_adminlog( LOG_ERR, "Permission denied-- user not allowed to delete, \ pause, or resume print job. User name: %s. Printer name: %s.", uidtoname(user->uid), PRINTERNAME(snum) ); |