@@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier arg1, arg2, arg3; @@ ssize_t d_show(struct device * - arg1 + dev , struct device_attribute * - arg2 + attr , char * - arg3 + buf ) { <... ( - arg1 + dev | - arg2 + attr | - arg3 + buf ) ...> } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - sprintf(buf, + sysfs_emit(buf, ...); ...> } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - snprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - scnprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; expression chr; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... return - strcpy(buf, chr); + sysfs_emit(buf, chr); ...> } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - sprintf(buf, + sysfs_emit(buf, ...); ...> return len; } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - snprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> return len; } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... len = - scnprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> return len; } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; identifier len; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { <... - len += scnprintf(buf + len, PAGE_SIZE - len, + len += sysfs_emit_at(buf, len, ...); ...> return len; } @@ //identifier d_show =~ "^.*show.*$"; identifier d_show; identifier dev, attr, buf; expression chr; @@ ssize_t d_show(struct device *dev, struct device_attribute *attr, char *buf) { - strcpy(buf, chr); - return strlen(buf); + return sysfs_emit(buf, chr); } @@ identifier k_show =~ "^.*show.*$"; identifier arg1, arg2, arg3; @@ ssize_t k_show(struct kobject * - arg1 + kobj , struct kobj_attribute * - arg2 + attr , char * - arg3 + buf ) { ... ( - arg1 + kobj | - arg2 + attr | - arg3 + buf ) ... } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { <... return - sprintf(buf, + sysfs_emit(buf, ...); ...> } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { <... return - snprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { <... return - scnprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; expression chr; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { <... return - strcpy(buf, chr); + sysfs_emit(buf, chr); ...> } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; identifier len; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { <... len = - sprintf(buf, + sysfs_emit(buf, ...); ...> return len; } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; identifier len; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { <... len = - snprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> return len; } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; identifier len; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { <... len = - scnprintf(buf, PAGE_SIZE, + sysfs_emit(buf, ...); ...> return len; } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; identifier len; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { <... - len += scnprintf(buf + len, PAGE_SIZE - len, + len += sysfs_emit_at(buf, len, ...); ...> return len; } @@ identifier k_show =~ "^.*show.*$"; identifier kobj, attr, buf; expression chr; @@ ssize_t k_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { - strcpy(buf, chr); - return strlen(buf); + return sysfs_emit(buf, chr); } // Rename the sysfs_emit assigned variables not named len and not already int // and set the name to len and type to int @not_int_not_len exists@ type T != int; identifier x != len; position p; identifier sysfs =~ "^sysfs_emit.*$"; assignment operator aop; @@ T x@p; ... x aop sysfs(...) ... @@ type not_int_not_len.T; identifier not_int_not_len.x; position not_int_not_len.p; @@ - T x@p; + int len; <... - x + len ...> // Rename the already int sysfs_emit assigned variables not named len // and set the name to len @int_not_len exists@ type T = int; identifier x != len; position p; identifier sysfs =~ "^sysfs_emit.*$"; assignment operator aop; @@ T x@p; ... x aop sysfs(...) ... @@ type int_not_len.T; identifier int_not_len.x; position int_not_len.p; @@ - T x@p; + int len; <... - x + len ...> // Rename the non-int int sysfs_emit assigned variables named len // and set the type to int @not_int_has_len exists@ type T != int; identifier x = len; position p; identifier sysfs =~ "^sysfs_emit.*$"; assignment operator aop; @@ T x@p; ... x aop sysfs(...) ... @@ type not_int_has_len.T; identifier not_int_has_len.x; position not_int_has_len.p; @@ - T x@p; + int len;